2019-01-02 00:00:53 +00:00
|
|
|
export type TStatusGroup = 'clientError' | 'serverError';
|
2017-04-06 15:00:38 +00:00
|
|
|
|
|
|
|
export class HttpStatus {
|
2021-08-16 13:36:41 +00:00
|
|
|
public static statusMap: { [key: string]: any } = {};
|
|
|
|
public static addStatus(statusStringArg: string, statusArg: any) {
|
2019-01-02 01:08:12 +00:00
|
|
|
HttpStatus.statusMap[statusStringArg] = statusArg;
|
|
|
|
}
|
2021-08-16 13:36:41 +00:00
|
|
|
public static getHttpStatusByString(codeStringArg: string): HttpStatus {
|
2021-08-19 16:40:04 +00:00
|
|
|
let statusInstance: HttpStatus;
|
|
|
|
try {
|
|
|
|
statusInstance = new HttpStatus.statusMap[codeStringArg]();
|
|
|
|
} catch {
|
|
|
|
console.log('unknown status')
|
2021-08-19 16:42:52 +00:00
|
|
|
return new HttpStatus({
|
|
|
|
code: 0,
|
|
|
|
text: 'unknown status',
|
|
|
|
description: `The status ${codeStringArg} is not known.`
|
|
|
|
});
|
2021-08-19 16:40:04 +00:00
|
|
|
}
|
2019-01-02 01:08:12 +00:00
|
|
|
return statusInstance;
|
2019-01-02 00:00:53 +00:00
|
|
|
}
|
2019-01-02 00:29:35 +00:00
|
|
|
public code: number;
|
|
|
|
public text: string;
|
|
|
|
public description: string;
|
2019-01-02 00:00:53 +00:00
|
|
|
constructor(optionsArg: { code: number; text: string; description: string }) {
|
|
|
|
this.code = optionsArg.code;
|
|
|
|
this.text = optionsArg.text;
|
|
|
|
this.description = optionsArg.description;
|
2017-04-06 15:00:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-02 00:00:53 +00:00
|
|
|
export * from './smartstatus.classes.http.1xx';
|
|
|
|
export * from './smartstatus.classes.http.2xx';
|
|
|
|
export * from './smartstatus.classes.http.3xx';
|
|
|
|
export * from './smartstatus.classes.http.4xx';
|
|
|
|
export * from './smartstatus.classes.http.5xx';
|