excalibur

Last updated:

0 purchases

excalibur Image
excalibur Images
Add to Cart

Description:

excalibur

Excalibur #



A Flutter package for handling exceptions in a clean and simple way.
Usage #
// Import the package
import 'package:excalibur/excalibur.dart';

// 1. Define your custom exceptions by extending the `BladeException` class
class CustomException implements BladeException {
// The error code associated with the exception
@override
int get code => 1;

// The message that will be displayed to the user
@override
String get message => 'Custom Exception Message';

// Whether the error page replaces the current page or not
@override
bool get replace => false;
}

void main() {
final _exceptions = [
// 2. Register your custom exceptions
CustomException(),
];
// Initialize an instance of Excalibur
final excalibur = Excalibur(
context,
exceptions: _exceptions,
unknownException: UnknownNumberException(),
builder: (exception) => ErrorPage(exception: exception),
);
// Inject the instance of Excalibur into your app or call it directly
excalibur.handleException(e as BladeException); // e is the exception

// 3. Throw your custom exceptions
throw CustomException();
// or
excalibur.throwException(1);
}
copied to clipboard

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.