我試圖壓制這個警告:
Warning: inherit from a more precise exception type like ValueError, IOError or OSError. If these don't suit, inherit from CatchableError or Defect. [InheritFromException]
我試過這個:
type
ReturnException* = ref object of Exception {.warning[InheritFromException]:off.}
value*: BaseType
uj5u.com熱心網友回復:
用這個:
type
ReturnException* = ref object of CatchableError
要么 :
type
ReturnException* = ref object of Defect
不同之處在于 aCatchableException可以被 捕獲try/except,而 aDefect總是導致程式退出。
uj5u.com熱心網友回復:
警告編譯指示是一個打開和關閉的開關。所以你需要做這樣的事情:
{.warning[InheritFromException]:off.}
type
ReturnException* = ref object of Exception
value*: BaseType
{.warning[InheritFromException]:on.}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/437715.html
