@fmal/http-service
Version:
A HTTP service - orignally @cerebral/http
23 lines (21 loc) • 450 B
JavaScript
export default class HttpServiceError extends Error {
constructor(type, status, headers, result, message = null) {
super(message);
this.name = 'HttpServiceError';
this.type = type || 'http';
this.response = {
status,
headers,
result
};
}
toJSON() {
return {
type: this.type,
name: this.name,
message: this.message,
response: this.response,
stack: this.stack
};
}
}