-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
417509c
commit 40e22c6
Showing
4 changed files
with
111 additions
and
10 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
apps/server/src/modules/group/loggable/unknown-query-type-loggable-exception.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { UnknownQueryTypeLoggableException } from './unknown-query-type-loggable-exception'; | ||
|
||
describe('UnknownQueryTypeLoggableException', () => { | ||
describe('getLogMessage', () => { | ||
const setup = () => { | ||
const unknownQueryType = 'unknwon'; | ||
|
||
const exception = new UnknownQueryTypeLoggableException(unknownQueryType); | ||
|
||
return { | ||
exception, | ||
unknownQueryType, | ||
}; | ||
}; | ||
|
||
it('should log the correct message', () => { | ||
const { exception, unknownQueryType } = setup(); | ||
|
||
const result = exception.getLogMessage(); | ||
|
||
expect(result).toEqual({ | ||
type: 'INTERNAL_SERVER_ERROR', | ||
stack: expect.any(String), | ||
message: 'Unable to process unknown query type for class years.', | ||
data: { | ||
unknownQueryType, | ||
}, | ||
}); | ||
}); | ||
}); | ||
}); |
19 changes: 19 additions & 0 deletions
19
apps/server/src/modules/group/loggable/unknown-query-type-loggable-exception.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { ErrorLogMessage, Loggable, LogMessage, ValidationErrorLogMessage } from '@src/core/logger'; | ||
import { InternalServerErrorException } from '@nestjs/common'; | ||
|
||
export class UnknownQueryTypeLoggableException extends InternalServerErrorException implements Loggable { | ||
constructor(private readonly unknownQueryType: string) { | ||
super(); | ||
} | ||
|
||
getLogMessage(): LogMessage | ErrorLogMessage | ValidationErrorLogMessage { | ||
return { | ||
type: 'INTERNAL_SERVER_ERROR', | ||
stack: this.stack, | ||
message: 'Unable to process unknown query type for class years.', | ||
data: { | ||
unknownQueryType: this.unknownQueryType, | ||
}, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters