Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BC-8531 add original error message to etherpad error #5392

Merged
merged 3 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading