ServiceError class

Exception class for service-related errors in the Calljmp SDK.

ServiceError encapsulates both a human-readable error message and a specific error code that can be used for programmatic error handling.

Usage

try {
  await calljmp.users.get('user_id');
} catch (e) {
  if (e is ServiceError) {
    switch (e.code) {
      case ServiceErrorCode.notFound:
        print('User not found');
        break;
      case ServiceErrorCode.unauthorized:
        print('Authentication required');
        break;
      default:
        print('Error: ${e.message}');
    }
  }
}
Implemented types

Constructors

ServiceError(String message, ServiceErrorCode code)
Creates a ServiceError with the specified message and code.
ServiceError.fromCode(ServiceErrorCode code)
Creates a ServiceError from a ServiceErrorCode with a default message.
factory
ServiceError.fromJson(Map<String, dynamic> json)
Creates a ServiceError from a JSON response.
factory

Properties

code ServiceErrorCode
The specific error code indicating the type of error.
final
hashCode int
The hash code for this object.
no setterinherited
message String
The human-readable error message.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
statusCode int
Returns the HTTP status code associated with this error.
no setter

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() Map<String, dynamic>
Converts this ServiceError to a JSON representation.
toString() String
Returns a string representation of this ServiceError.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited