src/app/shared/model/error.model.ts
Generic App Error
Properties |
Methods |
|
constructor(message: string)
|
||||||||
Defined in src/app/shared/model/error.model.ts:9
|
||||||||
Constructor
Parameters :
|
getMessage |
getMessage()
|
Defined in src/app/shared/model/error.model.ts:34
|
Get message
Returns :
string
|
Static is | ||||||||
is(error: )
|
||||||||
Defined in src/app/shared/model/error.model.ts:25
|
||||||||
Verify the object is an HttpAppError
Parameters :
Returns :
AppError
|
message |
message:
|
Type : string
|
Defined in src/app/shared/model/error.model.ts:9
|
Message |
export class AppError {
/**
* Message
*/
message: string;
/**
* Constructor
* @param {string} message
*/
constructor(message: string) {
this.message = message;
}
/**
* Verify the object is an HttpAppError
*
* @param error
* @returns {boolean}
*/
static is(error): error is AppError {
return true;
}
/**
* Get message
*
* @returns {string}
*/
getMessage() {
return this.message;
}
}
/**
* API Error
*/
export class HttpAppError extends AppError {
/**
* Status code
*/
httpStatusCode: number;
/**
* Constructor
* @param {string} message
* @param {number} httpStatusCode
*/
constructor(message: string, httpStatusCode: number) {
super(message);
this.httpStatusCode = httpStatusCode;
}
/**
* Verify the object is an HttpAppError
*
* @param error
* @returns {boolean}
*/
static is(error): error is HttpAppError {
return true;
}
/**
* Verify the object is an HttpAppError
* and the status code equal to 404
*
* @param error
* @returns {boolean}
*/
static is404(error): error is HttpAppError {
return error.httpStatusCode === 404;
}
/**
* Verify the object is an HttpAppError
* and the status code equal to 400
*
* @param error
* @returns {boolean}
*/
static is400(error): error is HttpAppError {
return error.httpStatusCode === 400;
}
/**
* Get message
*
* @returns {string}
*/
getMessage() {
return super.getMessage();
}
}