I'm trying to suppress this warning:
Warning: inherit from a more precise exception type like ValueError, IOError or OSError. If these don't suit, inherit from CatchableError or Defect. [InheritFromException]
And I tried this:
type
ReturnException* = ref object of Exception {.warning[InheritFromException]:off.}
value*: BaseType
CodePudding user response:
Use this:
type
ReturnException* = ref object of CatchableError
or :
type
ReturnException* = ref object of Defect
The difference is that a CatchableException
can be caught by try/except
, while a Defect
always causes the program to exit.
CodePudding user response:
The warning pragma is a switch that turns on and off. So you need to do something like this:
{.warning[InheritFromException]:off.}
type
ReturnException* = ref object of Exception
value*: BaseType
{.warning[InheritFromException]:on.}