CI: Update Pages (2025-11-23 11:20:49)
This commit is contained in:
25
v0.1.0/src/Errors/InvalidHttpMethodError.ts
Normal file
25
v0.1.0/src/Errors/InvalidHttpMethodError.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* Represents an error thrown when an incoming HTTP method
|
||||
* is not among the recognized set of valid HTTP methods.
|
||||
*
|
||||
* This is typically used in routers or request dispatchers
|
||||
* to enforce allowed methods and produce 405-like behavior.
|
||||
*/
|
||||
export class InvalidHttpMethodError extends Error {
|
||||
/**
|
||||
* The invalid method that triggered this error.
|
||||
*/
|
||||
public readonly method: unknown;
|
||||
|
||||
/**
|
||||
* A fixed HTTP status code representing "Method Not Allowed".
|
||||
*/
|
||||
public readonly status: number = 405;
|
||||
|
||||
constructor(method: unknown) {
|
||||
const label = typeof method === 'string' ? method : '[non-string]';
|
||||
super(`Unsupported HTTP method: ${label}`);
|
||||
this.name = 'InvalidHttpMethodError';
|
||||
this.method = method;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user