Skip to content

Commit

Permalink
Add message for instrument creation problems
Browse files Browse the repository at this point in the history
Change-Id: I1d91d7ea3a66cdec62d9c667eeebc30d5bd1e30b
  • Loading branch information
bpedersen2 committed Sep 15, 2023
1 parent 1a85a21 commit 1d8792d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/instruments/instruments.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,13 @@ export class InstrumentsController {
const instrument =
await this.instrumentsService.create(createInstrumentDto);
return instrument;
} catch (e) {
} catch (error) {
let message;
if (error instanceof Error) message = error.message;
else message = String(error);
// we'll proceed, but let's report it
throw new HttpException(
"Instrument with the same unique name already exists",
`Instrument with the same unique name already exists: ${message}`,
HttpStatus.BAD_REQUEST,
);
}
Expand Down

0 comments on commit 1d8792d

Please sign in to comment.