HttpStatus constructor

HttpStatus({
  1. required int code,
  2. required String name,
  3. required String description,
})

Creates a new instance of HttpStatus with the provided code, name, and description. The constructor validates the status code to ensure it is within the acceptable range of 0 to 999, inclusive. If the given code falls outside this range, it throws an ArgumentError.


final HttpStatus successStatus =
  HttpStatus(code: 200, name: 'OK', description: 'Request succeeded.');

Implementation

HttpStatus({
  required this.code,
  required this.name,
  required this.description,
}) {
  if (code < 0 || code > 999) {
    throw ArgumentError.value(
      code,
      'code',
      'Must be between 0 (inclusive) and 999 (inclusive)',
    );
  }
}