package haxe
extends NativeException
extended by Error, ValueException
Available on all platforms
Base class for exceptions.
If this class (or derivatives) is used to catch an exception, then haxe.CallStack.exceptionStack() will not return a stack for the exception caught. Use haxe.Exception.stack property instead:
try {
throwSomething();
} catch(e:Exception) {
trace(e.stack);
} Custom exceptions should extend this class:
class MyException extends haxe.Exception {}
//...
throw new MyException('terrible exception'); haxe.Exception is also a wildcard type to catch any exception:
try {
throw 'Catch me!';
} catch(e:haxe.Exception) {
trace(e.message); // Output: Catch me!
} To rethrow an exception just throw it again. Haxe will try to rethrow an original native exception whenever possible.
try {
var a:Array<Int> = null;
a.push(1); // generates target-specific null-pointer exception
} catch(e:haxe.Exception) {
throw e; // rethrows native exception instead of haxe.Exception
}
staticcaught(value:Any):ExceptionAvailable on cs
staticthrown(value:Any):AnyAvailable on cs
new(message:String, ?previous:Exception, ?native:Any)Create a new Exception instance.
The previous argument could be used for exception chaining.
The native argument is for internal usage only. There is no need to provide native argument manually and no need to keep it upon extending haxe.Exception unless you know what you're doing.
read onlymessage:StringException message.
read onlynative:AnyNative exception, which caused this exception.
read onlyprevious:Null<Exception>Contains an exception, which was passed to previous constructor argument.
read onlystack:CallStackThe call stack at the moment of the exception creation.
details():StringDetailed exception description.
Includes message, stack and the chain of previous exceptions (if set).
toString():StringReturns exception message.
unwrap():AnyAvailable on cs
© 2005–2020 Haxe Foundation
Licensed under a MIT license.
https://api.haxe.org/haxe/Exception.html