import httpclient
# testing Exceptions for getcontent
var ct:string
try:
ct = getcontent("http://google.com/",timeout = 8000)
except ValueError:
echo "Value error " & getCurrentExceptionMsg()
except OSError:
echo "OS error " & getCurrentExceptionMsg()
except HttpRequestError:
echo "HttpRequest Error " & getCurrentExceptionMsg()
except OverflowError:
echo "Overflow Error " & getCurrentExceptionMsg()
except TimeoutError:
echo "TimeoutError: " & getCurrentExceptionMsg()
except ProtocolError:
echo "Protocol Error " & getCurrentExceptionMsg()
except :
echo "Exception " & getCurrentExceptionMsg()
finally:
echo "Done"
Results in :
Error: undeclared identifier: 'TimeoutError'
Version :
Nim Compiler Version 0.12.0 (2015-10-28) [Linux: amd64]
Copyright (c) 2006-2015 by Andreas Rumpf
Exceptions as stated in manual.
Am I doing this wrong ?
TimeoutError is defined in the net module so you need to import the net module.
The httpclient module should probably export it.
Thank you.
Yes, export or mentioning this fact in the manual might help too.