Skip to content

Commit c2fc413

Browse files
move error into the exception itself
Signed-off-by: Thomas Poignant <[email protected]>
1 parent 964070d commit c2fc413

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

libs/shared/ofrep-core/src/lib/api/errors.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export class OFREPApiUnauthorizedError extends OFREPApiError {
3232
super(undefined, response, message, options);
3333
Object.setPrototypeOf(this, OFREPApiUnauthorizedError.prototype);
3434
this.name = OFREPApiUnauthorizedError.name;
35+
this.message = message ?? 'OFREP request failed: unauthorized';
3536
}
3637
}
3738

@@ -40,6 +41,7 @@ export class OFREPForbiddenError extends OFREPApiError {
4041
super(undefined, response, message, options);
4142
Object.setPrototypeOf(this, OFREPForbiddenError.prototype);
4243
this.name = OFREPForbiddenError.name;
44+
this.message = message ?? 'OFREP request failed: forbidden';
4345
}
4446
}
4547

libs/shared/ofrep-core/src/lib/api/ofrep-api.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,15 @@ export class OFREPApi {
8484
}
8585

8686
if (response.status === 401) {
87-
throw new OFREPApiUnauthorizedError(response, 'OFREP request failed: unauthorized');
87+
throw new OFREPApiUnauthorizedError(response);
8888
}
8989

9090
if (response.status === 403) {
91-
throw new OFREPForbiddenError(response, 'OFREP request failed: forbidden');
91+
throw new OFREPForbiddenError(response);
9292
}
9393

9494
if (response.status === 429) {
95-
throw new OFREPApiTooManyRequestsError(response, 'OFREP request failed: too many requests');
95+
throw new OFREPApiTooManyRequestsError(response);
9696
}
9797

9898
if (response.status === 200 && !this.isJsonMime(response)) {

0 commit comments

Comments
 (0)