errorMessage method

String errorMessage(
  1. BuildContext context, {
  2. String? badRequestMessage,
  3. String? unauthorizedMessage,
  4. String? paymentRequiredMessage,
  5. String? loginFailedMessage,
  6. String? unauthenticatedMessage,
  7. String? forbiddenMessage,
  8. String? notFoundMessage,
  9. String? methodNotAllowedMessage,
  10. String? notAcceptableMessage,
  11. String? internalServerErrorMessage,
  12. String? notImplementedMessage,
  13. String? badGatewayMessage,
})

Implementation

String errorMessage(
  BuildContext context, {
  String? badRequestMessage,
  String? unauthorizedMessage,
  String? paymentRequiredMessage,
  String? loginFailedMessage,
  String? unauthenticatedMessage,
  String? forbiddenMessage,
  String? notFoundMessage,
  String? methodNotAllowedMessage,
  String? notAcceptableMessage,
  String? internalServerErrorMessage,
  String? notImplementedMessage,
  String? badGatewayMessage,
}) {
  switch (type) {
    case ErrorType.badRequest:
      return badRequestMessage ?? type.rawValue(context);
    case ErrorType.unauthorized:
      return unauthenticatedMessage ?? type.rawValue(context);
    case ErrorType.paymentRequired:
      return paymentRequiredMessage ?? type.rawValue(context);
    case ErrorType.loginFailed:
      return loginFailedMessage ?? type.rawValue(context);
    case ErrorType.unauthenticated:
      return unauthenticatedMessage ?? type.rawValue(context);
    case ErrorType.unknown:
      return message ?? type.rawValue(context);
    case ErrorType.forbidden:
      return forbiddenMessage ?? type.rawValue(context);
    case ErrorType.notFound:
      return notFoundMessage ?? type.rawValue(context);
    case ErrorType.methodNotAllowed:
      return methodNotAllowedMessage ?? type.rawValue(context);
    case ErrorType.notAcceptable:
      return notAcceptableMessage ?? type.rawValue(context);
    case ErrorType.internalServerError:
      return internalServerErrorMessage ?? type.rawValue(context);
    case ErrorType.notImplemented:
      return notImplementedMessage ?? type.rawValue(context);
    case ErrorType.badGateway:
      return badGatewayMessage ?? type.rawValue(context);
    default:
      return "Unknown Error Message";
  }
}