Hi,
i am playing a bit with nim to get my feet wet. Currently I stuck with a compile error I found no explaination for. Please don't be rough to me, I now the code might be terrible... Here it is:
import os
import json
type GrubifyError = object of Exception
type Settings = object
rootDev*: string
grubDevLabel*: string
title*: string
rawSettings: JsonNode
errorMsg*: string
proc readSettings(): Settings =
var settingsFile: string = "./grubify.json"
if fileExists(settingsFile):
try:
result.rawSettings = parseFile(settingsFile)
except:
raise NewException(GrubifyError, "Couldn't parse " & settingsFile)
#result.errorMsg = "Error"
when isMainModule:
var x: Settings = readSettings()
if x.errorMsg == nil:
echo x.rawSettings
else:
echo x.errorMsg
The compiler throws "Error: undeclared identifier: NewException" and I have no idea why. I made another small snipped and tested the newException statement without an error (it was a try with an assert(0 == 1)).
Thanks for your help.