Skip to main content

sinew_exception 1.0.0 copy "sinew_exception: ^1.0.0" to clipboard
sinew_exception: ^1.0.0 copied to clipboard

SinewException types, handlers, processCall, CrashReporter and Localizer.

example/main.dart

// ignore_for_file: avoid_print

import 'package:sinew_exception/sinew_exception.dart';
import 'package:sinew_models/sinew_models.dart';

Future<String> loadOrder() async {
  throw const FormatException('not json');
}

Future<void> main() async {
  // region guard
  // A guard turns whatever a call throws into a typed failure, once, where it
  // happened. The handlers say which errors mean what for this layer.
  final result = await processCall<String>(
    'ORD',
    'load',
    ExceptionLayer.repository,
    [
      ExceptionHandler(
        (error) => error is FormatException,
        (error) =>
            const ParseException('ORD', ExceptionLayer.repository, 'load'),
      ),
    ],
    loadOrder,
  );
  // endregion

  result.when(
    success: (order, message) => print('Loaded $order'),
    // The code reads module-layer-function-type, so a support report points at
    // the exact call.
    failure: (error, stackTrace) => print('Failed with ${error.code}'),
  );
}
0
likes
160
points
417
downloads

Documentation

Documentation
API reference

Publisher

verified publishersrctool.com

Weekly Downloads

SinewException types, handlers, processCall, CrashReporter and Localizer.

Repository (GitHub)
View/report issues
Contributing

Topics

#error-handling #exception #architecture #localization

License

Apache-2.0 (license)

Dependencies

sinew_models

More

Packages that depend on sinew_exception