0

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
pooooky
  • 490
  • 2
  • 12

2 Answers2

4

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.

ftherien
  • 153
  • 6
2

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.}
PMunch
  • 1,525
  • 11
  • 20