mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
20 lines
718 B
TypeScript
20 lines
718 B
TypeScript
/**
|
|
* An abstract class for all errors that could be thrown by Solid.
|
|
* All errors inheriting from this should fix the status code thereby hiding the HTTP internals from other components.
|
|
*/
|
|
export abstract class HttpError extends Error {
|
|
public statusCode: number;
|
|
|
|
/**
|
|
* Creates a new HTTP error. Subclasses should call this with their fixed status code.
|
|
* @param statusCode - HTTP status code needed for the HTTP response.
|
|
* @param name - Error name. Useful for logging and stack tracing.
|
|
* @param message - Message to be thrown.
|
|
*/
|
|
protected constructor(statusCode: number, name: string, message?: string) {
|
|
super(message);
|
|
this.statusCode = statusCode;
|
|
this.name = name;
|
|
}
|
|
}
|