AppException class

An application-defined failure, carrying its own code and statusCode.

HubException is sealed, so an application cannot slot its own failure types into the hierarchy — but everything that maps errors to the wire (the pipeline's errorMapper, the hub's upgrade path, the node gateway's registration handler) keys off HubException, and anything else becomes an opaque 500. This is the seam: translate the application's own exceptions into an AppException and they render with the intended status and code.

Middleware appErrors() => mapErrors((error, _) => switch (error) {
  MyDomainException e => HubResponse.error(
      AppException(code: e.code, message: e.message, statusCode: e.status)),
  _ => null, // rethrow; let the framework's errorMapper handle it
});

Prefer a built-in (NotFoundException, UnauthorizedException, ...) when one fits — they carry the ecosystem's stable ErrorCodes.

Inheritance

Constructors

AppException({required String code, required String message, required int statusCode})
Creates an application failure with an explicit code, message and statusCode.
const

Properties

code String
Stable, machine-readable error code (see ErrorCodes).
finalinherited
hashCode int
The hash code for this object.
no setterinherited
message String
Human-readable description of the failure.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
statusCode int
HTTP status code the pipeline should respond with.
finalinherited

Methods

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