errorMessage property

String? get errorMessage

Returns the error message if the error is an Exception with a message, otherwise returns the string representation of the error.

Implementation

String? get errorMessage => switch (error) {
      Exception(:String message) => message,
      _ => error?.toString(),
    };