Skip to content

Commit

Permalink
BC-6453 - extend error handling in AuthorizationErrorLoggableException
Browse files Browse the repository at this point in the history
  • Loading branch information
bergatco committed Jun 13, 2024
1 parent 7511741 commit 1ebdf2e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class AuthorizationClientAdapter {

return hasPermission;
} catch (error) {
throw new AuthorizationErrorLoggableException(error as Error, params);
throw new AuthorizationErrorLoggableException(error, params);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import { ErrorLogMessage } from '@src/core/logger/types';
import { AuthorizationBodyParams } from '../authorization-api-client';

export class AuthorizationErrorLoggableException extends ForbiddenException implements Loggable {
constructor(private readonly error: Error, private readonly params: AuthorizationBodyParams) {
constructor(private readonly error: unknown, private readonly params: AuthorizationBodyParams) {
super();
}

getLogMessage(): ErrorLogMessage {
const error = this.error instanceof Error ? this.error : new Error(JSON.stringify(this.error));
const message: ErrorLogMessage = {
type: 'INTERNAL_SERVER_ERROR',
error: this.error,
error,
stack: this.stack,
data: {
action: this.params.context.action,
Expand Down

0 comments on commit 1ebdf2e

Please sign in to comment.