handleError method

  1. @override
ErrorDetail handleError(
  1. String errorId,
  2. ErrorDetail error
)

Returns the ErrorDetail after manipulating an existing one.

Method that handles errors by parsing the raw response or custom input.

If other errors are to be added, then they will be handled here as if-else or switch-case.

Each error needs to be supplied an errorId, or null if a Generic Error were to be returned.

If error is passed, it can be manipulated within this method and return the modified ErrorDetail object.

Implementation

@override
ErrorDetail handleError(String errorId, ErrorDetail error) {
  switch (errorId) {
    case 'verifyClientId':
      error.title = 'Client ID Verification Error';
      break;
    case 'FetchId':
      error.title = 'Failed to Fetch Id';
      break;
    case 'Fetch-id-badrequest':
      error.title = 'Fetch Id Bad Request!';
      break;
    case 'fcm_register_client':
      error.title = 'Failed to register token!';
      break;
    case 'fcm_unregister_client':
      error.title = 'Failed to unregister token!';
      break;
    case 'fcm_notification':
      error.title = 'Failed to retrieve notification list!';
      break;
    case 'fcm_notification_mark':
      error.title = 'Failed to mark notification as seen!';
      break;
    default:
      error = RenovationController.genericError(error);
  }
  return error;
}