Skip to content

Commit

Permalink
BC-8531 add original error message to etherpad error
Browse files Browse the repository at this point in the history
  • Loading branch information
Loki-Afro committed Dec 10, 2024
1 parent 4da6d99 commit c8d89e2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,7 @@ 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, {});

Check failure on line 998 in apps/server/src/infra/etherpad-client/etherpad-client.adapter.spec.ts

View workflow job for this annotation

GitHub Actions / nest_lint

Replace `EtherpadErrorType.INTERNAL_ERROR,·{·padId:·groupId·},·undefined,·{}` with `⏎↹↹↹↹↹EtherpadErrorType.INTERNAL_ERROR,⏎↹↹↹↹↹{·padId:·groupId·},⏎↹↹↹↹↹undefined,⏎↹↹↹↹↹{}⏎↹↹↹↹`
await expect(service.deleteGroup(groupId)).rejects.toThrowError(exception);
});
});
Expand Down Expand Up @@ -1084,7 +1084,7 @@ 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, {});

Check failure on line 1087 in apps/server/src/infra/etherpad-client/etherpad-client.adapter.spec.ts

View workflow job for this annotation

GitHub Actions / nest_lint

Replace `EtherpadErrorType.BAD_REQUEST,·{·sessionId·},·undefined,·{}` with `⏎↹↹↹↹↹EtherpadErrorType.BAD_REQUEST,⏎↹↹↹↹↹{·sessionId·},⏎↹↹↹↹↹undefined,⏎↹↹↹↹↹{}⏎↹↹↹↹`
await expect(service.deleteSession(sessionId)).rejects.toThrowError(exception);
});
});
Expand Down Expand Up @@ -1150,7 +1150,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'

Check failure on line 25 in apps/server/src/infra/etherpad-client/loggable/etherpad-server-error-exception.spec.ts

View workflow job for this annotation

GitHub Actions / nest_lint

Insert `,`
},
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ 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));

Check failure on line 65 in apps/server/src/infra/etherpad-client/mappers/etherpad-response.mapper.ts

View workflow job for this annotation

GitHub Actions / nest_lint

Replace `type,·payload,·response.message,·ErrorUtils.createHttpExceptionOptions(response.message)` with `⏎↹↹↹type,⏎↹↹↹payload,⏎↹↹↹response.message,⏎↹↹↹ErrorUtils.createHttpExceptionOptions(response.message)⏎↹↹`
}

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

0 comments on commit c8d89e2

Please sign in to comment.