mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-25 03:06:31 -05:00
feat(note): handle unique publicId error
Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
parent
69561e5c63
commit
8201fb8c32
2 changed files with 9 additions and 1 deletions
|
@ -88,7 +88,7 @@ export class NotesController {
|
|||
}
|
||||
|
||||
@Post()
|
||||
@OpenApi(201, 413)
|
||||
@OpenApi(201, 409, 413)
|
||||
@Permissions(Permission.CREATE)
|
||||
async createNote(
|
||||
@RequestUser() user: User,
|
||||
|
|
|
@ -139,6 +139,14 @@ export class NotesService {
|
|||
throw new AlreadyInDBError(
|
||||
`A note with the alias '${alias}' already exists.`,
|
||||
);
|
||||
} else if ((e as Error).message.includes('publicId')) {
|
||||
this.logger.debug(
|
||||
`A note with the publicId '${newNote.publicId}' already exists.`,
|
||||
'createNote',
|
||||
);
|
||||
throw new AlreadyInDBError(
|
||||
`A note with the publicId '${newNote.publicId}' already exists.`,
|
||||
);
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue