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 11, 2023
1 parent 0f827b0 commit 72f9d46
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/instruments/instruments.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,16 @@ export class InstrumentsController {
@Body() createInstrumentDto: CreateInstrumentDto,
): Promise<Instrument> {
try {
const instrument = await this.instrumentsService.create(
createInstrumentDto,
);
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 72f9d46

Please sign in to comment.