ExceptionHandler class

Provides a hook for receiving unhandled errors/exceptions.

The default implementation of ExceptionHandler when used in AngularDart prints the error message directly to the JavaScript developer console.

It's possible to instead write a custom exception handler:

import 'package:ngdart/angular.dart';

import 'main.template.dart' as ng;

class MyExceptionHandler implements ExceptionHandler {
  @override
  void call(exception, [stackTrace, String reason]) {
    // Do something with this exception, like send to an online service.
  }
}

@GenerateInjector([
  ClassProvider(ExceptionHandler, useClass: MyExceptionHandler),
])
final InjectorFactory appInjector = ng.appInjector$Injector;

void main() {
  runApp(
    ng.createMyAppFactory(),
    createInjector: appInjector,
  );
}

Constructors

ExceptionHandler()
const

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

call(Object exception, [Object? stackTrace, String? reason]) → void
Handles an error or exception caught at runtime.
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

Static Methods

exceptionToString(Object exception, [Object? stackTrace, String? reason]) String
Internal use only: Converts a caught angular exception into a string.