add me point to load user data of current user
This commit is contained in:
parent
fac606cf97
commit
e5b5d7e67d
12 changed files with 215 additions and 67 deletions
|
|
@ -1,39 +1,46 @@
|
|||
export class ValidationError extends Error {
|
||||
statusCode = 400;
|
||||
constructor(message: string) {
|
||||
/**
|
||||
* Base class for all HTTP-related errors.
|
||||
* Extends the built-in Error with a status code and message
|
||||
* so that they can be handled in a consistent way.
|
||||
*/
|
||||
export class HttpError extends Error {
|
||||
public statusCode: number;
|
||||
|
||||
constructor(message: string, statusCode: number) {
|
||||
super(message);
|
||||
this.name = "ValidationError";
|
||||
this.statusCode = statusCode;
|
||||
|
||||
// Restore prototype chain (important when targeting ES5/ES2015+)
|
||||
Object.setPrototypeOf(this, new.target.prototype);
|
||||
}
|
||||
}
|
||||
|
||||
export class NotFoundError extends Error {
|
||||
statusCode = 404;
|
||||
export class ValidationError extends HttpError {
|
||||
constructor(message: string) {
|
||||
super(message);
|
||||
this.name = "NotFoundError";
|
||||
super(message, 400); // Bad Request
|
||||
}
|
||||
}
|
||||
|
||||
export class ConflictError extends Error {
|
||||
statusCode = 409;
|
||||
constructor(message: string) {
|
||||
super(message);
|
||||
this.name = "ConflictError";
|
||||
export class UnauthorizedError extends HttpError {
|
||||
constructor(message: string = "Unauthorized") {
|
||||
super(message, 401);
|
||||
}
|
||||
}
|
||||
|
||||
export class InternalServerError extends Error {
|
||||
statusCode = 500;
|
||||
constructor(message: string) {
|
||||
super(message);
|
||||
this.name = "InternalServerError";
|
||||
export class NotFoundError extends HttpError {
|
||||
constructor(message: string = "Resource not found") {
|
||||
super(message, 404);
|
||||
}
|
||||
}
|
||||
|
||||
export class UnauthorizedError extends Error {
|
||||
statusCode = 409;
|
||||
constructor(message: string) {
|
||||
super(message);
|
||||
this.name = "UnauthorizedError";
|
||||
export class ConflictError extends HttpError {
|
||||
constructor(message: string = "Conflict") {
|
||||
super(message, 409);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class InternalServerError extends HttpError {
|
||||
constructor(message: string = "Internal Server Error") {
|
||||
super(message, 500);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue