ExitCodeExceptionHandler class abstract interface

A strategy interface for mapping a specific Exception to a process exit code.

This interface allows you to define custom logic to translate different types of exceptions into meaningful exit codes for your application. It's especially useful for CLI tools, server applications, or embedded systems where specific exit codes are used to signal different kinds of failure conditions.

Example:

class CustomExitCodeMapper implements ExitCodeExceptionMapper {
  @override
  int getExitCode(Exception exception) {
    if (exception is FormatException) return 2;
    if (exception is FileSystemException) return 3;
    return 1; // generic failure
  }
}

You can combine multiple mappers or use this in a centralized shutdown strategy to ensure all errors are properly classified with standardized codes.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

getExitCode(Exception exception) int
Returns an integer exit code based on the given exception.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited