Skip to content

Commit

Permalink
BC-8531 add original error message to etherpad error (#5392)
Browse files Browse the repository at this point in the history
  • Loading branch information
Loki-Afro authored Dec 10, 2024
1 parent 062af47 commit 545982e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,12 @@ describe(EtherpadClientAdapter.name, () => {
it('should throw EtherpadErrorLoggableException', async () => {
const groupId = setup();

const exception = new EtherpadErrorLoggableException(EtherpadErrorType.INTERNAL_ERROR, { padId: groupId }, {});
const exception = new EtherpadErrorLoggableException(
EtherpadErrorType.INTERNAL_ERROR,
{ padId: groupId },
undefined,
{}
);
await expect(service.deleteGroup(groupId)).rejects.toThrowError(exception);
});
});
Expand Down Expand Up @@ -1084,7 +1089,12 @@ describe(EtherpadClientAdapter.name, () => {
it('should throw EtherpadErrorLoggableException', async () => {
const sessionId = setup();

const exception = new EtherpadErrorLoggableException(EtherpadErrorType.BAD_REQUEST, { sessionId }, {});
const exception = new EtherpadErrorLoggableException(
EtherpadErrorType.BAD_REQUEST,
{ sessionId },
undefined,
{}
);
await expect(service.deleteSession(sessionId)).rejects.toThrowError(exception);
});
});
Expand Down Expand Up @@ -1150,7 +1160,7 @@ describe(EtherpadClientAdapter.name, () => {
it('should throw EtherpadErrorLoggableException', async () => {
const padId = setup();

const exception = new EtherpadErrorLoggableException(EtherpadErrorType.BAD_REQUEST, { padId }, {});
const exception = new EtherpadErrorLoggableException(EtherpadErrorType.BAD_REQUEST, { padId }, undefined, {});
await expect(service.deletePad(padId)).rejects.toThrowError(exception);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export class EtherpadErrorLoggableException extends InternalServerErrorException
constructor(
private readonly type: EtherpadErrorType,
private readonly payload: EtherpadParams,
private readonly originalMessage: string | undefined,
private readonly exceptionOptions: HttpExceptionOptions
) {
super(type, exceptionOptions);
Expand All @@ -20,6 +21,7 @@ export class EtherpadErrorLoggableException extends InternalServerErrorException
data: {
userId,
parentId,
originalMessage: this.originalMessage,
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('EtherpadErrorLoggableException', () => {
const error = new Error('error');
const httpExceptionOptions = ErrorUtils.createHttpExceptionOptions(error);

const exception = new EtherpadErrorLoggableException(type, payload, httpExceptionOptions);
const exception = new EtherpadErrorLoggableException(type, payload, 'hugo ist nudeln', httpExceptionOptions);
const result = exception.getLogMessage();

expect(result).toStrictEqual({
Expand All @@ -22,6 +22,7 @@ describe('EtherpadErrorLoggableException', () => {
data: {
userId: 'userId',
parentId: 'parentId',
originalMessage: 'hugo ist nudeln',
},
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@ export class EtherpadResponseMapper {
payload: EtherpadParams,
response: T | Error
): EtherpadErrorLoggableException {
return new EtherpadErrorLoggableException(type, payload, ErrorUtils.createHttpExceptionOptions(response.message));
return new EtherpadErrorLoggableException(
type,
payload,
response.message,
ErrorUtils.createHttpExceptionOptions(response.message)
);
}

static mapEtherpadSessionsToSessions(etherpadSessions: unknown): Session[] {
Expand Down

0 comments on commit 545982e

Please sign in to comment.