Skip to content

Commit

Permalink
fix(data): make DataServiceError extend from Error (#3988)
Browse files Browse the repository at this point in the history
  • Loading branch information
rob4226 authored Aug 5, 2023
1 parent 65acf86 commit 0b98a65
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions modules/data/src/dataservices/data-service-error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ import { RequestData } from './interfaces';
* @param error the HttpErrorResponse or the error thrown by the service
* @param requestData the HTTP request information such as the method and the url.
*/
// If extend from Error, `dse instanceof DataServiceError` returns false
// in some (all?) unit tests so don't bother trying.
export class DataServiceError {
message: string | null;

export class DataServiceError extends Error {
constructor(public error: any, public requestData: RequestData | null) {
this.message = typeof error === 'string' ? error : extractMessage(error);
super(
typeof error === 'string' ? error : extractMessage(error) ?? undefined
);
this.name = this.constructor.name;
}
}

Expand Down

0 comments on commit 0b98a65

Please sign in to comment.