Skip to content

dart migrate for null-safety #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 16 additions & 15 deletions lib/http_exception.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'http_status.dart';
class HttpException implements Exception {
final int status;
final String message;
final Map<String, dynamic> data;
final Map<String, dynamic>? data;

const HttpException(
[this.status = HttpStatus.INTERNAL_SERVER_ERROR,
Expand All @@ -26,101 +26,102 @@ class HttpException implements Exception {

/// 400 Bad Request
class BadRequestException extends HttpException {
const BadRequestException([Map<String, dynamic> data, String detail = ''])
const BadRequestException([Map<String, dynamic>? data, String detail = ''])
: super(HttpStatus.BAD_REQUEST,
'Bad Request${detail != '' ? ': ' : ''}$detail', data);
}

/// 401 Unauthorized
class UnauthorizedException extends HttpException {
const UnauthorizedException([Map<String, dynamic> data, String detail = ''])
const UnauthorizedException([Map<String, dynamic>? data, String detail = ''])
: super(HttpStatus.UNAUTHORIZED,
'Unauthorized${detail != '' ? ': ' : ''}$detail', data);
}

/// 402 Payment Required
class PaymentRequiredException extends HttpException {
const PaymentRequiredException(
[Map<String, dynamic> data, String detail = ''])
[Map<String, dynamic>? data, String detail = ''])
: super(HttpStatus.PAYMENT_REQUIRED,
'Payment Required${detail != '' ? ': ' : ''}$detail', data);
}

/// 403 Forbidden
class ForbiddenException extends HttpException {
const ForbiddenException([Map<String, dynamic> data, String detail = ''])
const ForbiddenException([Map<String, dynamic>? data, String detail = ''])
: super(HttpStatus.FORBIDDEN,
'Forbidden${detail != '' ? ': ' : ''}$detail', data);
}

/// 404 Not Found
class NotFoundException extends HttpException {
const NotFoundException([Map<String, dynamic> data, String detail = ''])
const NotFoundException([Map<String, dynamic>? data, String detail = ''])
: super(HttpStatus.NOT_FOUND,
'Not Found${detail != '' ? ': ' : ''}$detail', data);
}

/// 405 Method Not Allowed
class MethodNotAllowed extends HttpException {
const MethodNotAllowed([Map<String, dynamic> data, String detail = ''])
const MethodNotAllowed([Map<String, dynamic>? data, String detail = ''])
: super(HttpStatus.METHOD_NOT_ALLOWED,
'Method Not Allowed${detail != '' ? ': ' : ''}$detail', data);
}

/// 406 Not Acceptable
class NotAcceptableException extends HttpException {
const NotAcceptableException([Map<String, dynamic> data, String detail = ''])
const NotAcceptableException([Map<String, dynamic>? data, String detail = ''])
: super(HttpStatus.NOT_ACCEPTABLE,
'Not Acceptable${detail != '' ? ': ' : ''}$detail', data);
}

/// 409 Conflict
class ConflictException extends HttpException {
const ConflictException([Map<String, dynamic> data, String detail = ''])
const ConflictException([Map<String, dynamic>? data, String detail = ''])
: super(HttpStatus.CONFLICT, 'Conflict${detail != '' ? ': ' : ''}$detail',
data);
}

/// 410 Gone
class GoneException extends HttpException {
const GoneException([Map<String, dynamic> data, String detail = ''])
const GoneException([Map<String, dynamic>? data, String detail = ''])
: super(HttpStatus.GONE, 'Gone${detail != '' ? ': ' : ''}$detail', data);
}

/// 412 Precondition Failed
class PreconditionFailedException extends HttpException {
const PreconditionFailedException(
[Map<String, dynamic> data, String detail = ''])
[Map<String, dynamic>? data, String detail = ''])
: super(HttpStatus.PRECONDITION_FAILED,
'Precondition Failed${detail != '' ? ': ' : ''}$detail', data);
}

/// 415 Unsupported Media Type
class UnsupportedMediaTypeException extends HttpException {
const UnsupportedMediaTypeException(
[Map<String, dynamic> data, String detail = ''])
[Map<String, dynamic>? data, String detail = ''])
: super(HttpStatus.UNSUPPORTED_MEDIA_TYPE,
'Unsupported Media Type${detail != '' ? ': ' : ''}$detail', data);
}

/// 429 Too Many Requests
class TooManyRequestsException extends HttpException {
const TooManyRequestsException(
[Map<String, dynamic> data, String detail = ''])
[Map<String, dynamic>? data, String detail = ''])
: super(429, 'Too Many Requests${detail != '' ? ': ' : ''}$detail', data);
}

/// 501 Not Implemented
class NotImplementedException extends HttpException {
const NotImplementedException([Map<String, dynamic> data, String detail = ''])
const NotImplementedException(
[Map<String, dynamic>? data, String detail = ''])
: super(HttpStatus.NOT_IMPLEMENTED,
'Not Implemented${detail != '' ? ': ' : ''}$detail', data);
}

/// 503 Service Unavailable
class ServiceUnavailableException extends HttpException {
const ServiceUnavailableException(
[Map<String, dynamic> data, String detail = ''])
[Map<String, dynamic>? data, String detail = ''])
: super(HttpStatus.SERVICE_UNAVAILABLE,
'Service Unavailable${detail != '' ? ': ' : ''}$detail', data);
}
Loading