-
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.
Browse files
Browse the repository at this point in the history
* add new ContextExternalToolNameAlreadyExistsLoggableException * adjust ToolParameterDuplicateLoggableException * adjust ToolParameterRequiredLoggableException * adjust ToolParameterTypeMismatchLoggableException * adjust ToolParameterUnknownLoggableException * adjust ToolParameterValueMissingLoggableException * adjust ToolParameterValueRegexLoggableException
- Loading branch information
Showing
34 changed files
with
302 additions
and
81 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
.../common/domain/error/context-external-tool-name-already-exists.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 { ContextExternalToolNameAlreadyExistsLoggableException } from './context-external-tool-name-already-exists.loggable-exception'; | ||
|
||
describe(ContextExternalToolNameAlreadyExistsLoggableException.name, () => { | ||
describe('getLogMessage', () => { | ||
const setup = () => { | ||
const exception: ContextExternalToolNameAlreadyExistsLoggableException = | ||
new ContextExternalToolNameAlreadyExistsLoggableException('toolid', 'toolname'); | ||
|
||
return { | ||
exception, | ||
}; | ||
}; | ||
|
||
it('should return log message', () => { | ||
const { exception } = setup(); | ||
|
||
const result = exception.getLogMessage(); | ||
|
||
expect(result).toEqual({ | ||
type: 'CONTEXT_EXTERNAL_TOOL_NAME_ALREADY_EXISTS', | ||
message: | ||
'A tool with the same name is already assigned to this course. Tool names must be unique within a course.', | ||
stack: exception.stack, | ||
data: { | ||
toolId: 'toolid', | ||
toolName: 'toolname', | ||
}, | ||
}); | ||
}); | ||
}); | ||
}); |
34 changes: 34 additions & 0 deletions
34
.../tool/common/domain/error/context-external-tool-name-already-exists.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,34 @@ | ||
import { BusinessError } from '@shared/common'; | ||
import { ErrorLogMessage, Loggable, LogMessage, ValidationErrorLogMessage } from '@src/core/logger'; | ||
import { HttpStatus } from '@nestjs/common'; | ||
import { EntityId } from '@shared/domain/types'; | ||
|
||
export class ContextExternalToolNameAlreadyExistsLoggableException extends BusinessError implements Loggable { | ||
constructor(private readonly toolId: EntityId | undefined, private readonly toolName: string | undefined) { | ||
super( | ||
{ | ||
type: 'CONTEXT_EXTERNAL_TOOL_NAME_ALREADY_EXISTS', | ||
title: 'Toolname already exists', | ||
defaultMessage: | ||
'A tool with the same name is already assigned to this course. Tool names must be unique within a course.', | ||
}, | ||
HttpStatus.BAD_REQUEST, | ||
{ | ||
toolId, | ||
toolName, | ||
} | ||
); | ||
} | ||
|
||
getLogMessage(): LogMessage | ErrorLogMessage | ValidationErrorLogMessage { | ||
return { | ||
type: this.type, | ||
message: this.message, | ||
stack: this.stack, | ||
data: { | ||
toolId: this.toolId, | ||
toolName: this.toolName, | ||
}, | ||
}; | ||
} | ||
} |
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
26 changes: 20 additions & 6 deletions
26
...erver/src/modules/tool/common/domain/error/tool-parameter-duplicate.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
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
26 changes: 19 additions & 7 deletions
26
...server/src/modules/tool/common/domain/error/tool-parameter-required.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
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
24 changes: 18 additions & 6 deletions
24
...r/src/modules/tool/common/domain/error/tool-parameter-type-mismatch.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
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
26 changes: 20 additions & 6 deletions
26
.../server/src/modules/tool/common/domain/error/tool-parameter-unknown.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
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
28 changes: 21 additions & 7 deletions
28
...r/src/modules/tool/common/domain/error/tool-parameter-value-missing.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
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
Oops, something went wrong.