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

Exception Handler simplifies exception handling in Dart and Flutter applications. It offers a streamlined approach to managing exceptions with customizable error messages and flexible exception handling.

Exception Handler


Exception Handler #

Exception Handler is a Dart package that provides a simple and flexible way to handle exceptions in your Dart/Flutter applications. It allows users to specify which types of exceptions they want to handle and provides customizable error messages for different exception scenarios.

Features #

  • Handle exceptions easily with a single function call.
  • Specify which types of exceptions to handle.
  • Customize error messages for different exception scenarios.
  • Lightweight and easy to integrate into your projects.

Installation #

To use Exception Handler in your Dart/Flutter project, add the following line to your pubspec.yaml file:

dependencies:
  exception_handler: ^1.0.0

Then, run dart pub get to install the package.

Usage #

Import the package into your Dart file:

import 'package:exception_handler/exception_handler.dart';

Use the handleExceptions function to handle exceptions in your code:

void main() async {
  try {
    await ExceptionHandler.handleExceptions(
      () async {
        // Code that might cause exceptions
        await signinWithGoogle();
      },
      needFirebaseAuthException: true, // Specify which exceptions to handle
      needFirebaseException: false, // Specify other exceptions to handle
    );
  } catch (e) {
    // Handle the exceptions thrown by the handleExceptions function
    print('An exception occurred: $e');
  }
}

Customization #

You can customize the behavior of the handleExceptions function by specifying which types of exceptions to handle and providing custom error messages for different exception scenarios.

Example:

// Specify custom error messages for different exception types
class JFirebaseAuthException implements Exception {
  final String message;

  JFirebaseAuthException(this.message);
}

// Use the handleExceptions function with custom exception handling logic
await ExceptionHandler.handleExceptions(
  () async {
    // Code that might cause exceptions
  },
  needFirebaseAuthException: true, // Specify which exceptions to handle
);

License #

This package is distributed under the GNU License. See the LICENSE file for more information.


5
likes
0
points
40
downloads

Publisher

unverified uploader

Weekly Downloads

Exception Handler simplifies exception handling in Dart and Flutter applications. It offers a streamlined approach to managing exceptions with customizable error messages and flexible exception handling.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

cloud_firestore, firebase_auth, firebase_core, firebase_storage, flutter

More

Packages that depend on exception_helper