Standard Library
class LogicException
An error that signals a mistake in the program's own logic, such as using an object in the wrong state.
since 0.1.0-alpha.1linuxwindowswasm
- bases
Exception,ILogicException
Overview
Nothing in the standard library throws it; it is provided for your own code, and it is kept separate from RuntimeException so the two can be handled differently.
Examples
try {
throw LogicException("closed twice");
} catch (RuntimeException e) {
console.writeln("runtime");
} catch (LogicException e) {
console.writeln("logic: ${e.message}");
}
logic: closed twice
Constructors
new
new(string msg)Creates a logic error with a message.
Parameters
- msg
- The text describing what went wrong.
Examples
LogicException e = LogicException("wrong state");
console.writeln(e.message);
wrong state
See also
- ILogicException — The interface of errors that come from a mistake in how the program was written, such as calling something in the wrong state.
- RuntimeException — The error the standard library throws when an operation fails at run time.