-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #295 from swisstopo/feature/asset-238-fehler-bei-g…
…leichem-workgroup-namen Feature 238: Fehler bei gleichem Workgroup-Namen ordentlich anzeigen
- Loading branch information
Showing
12 changed files
with
109 additions
and
13 deletions.
There are no files selected for viewing
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
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
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
37 changes: 37 additions & 0 deletions
37
apps/server-asset-sg/src/core/exception-filters/prisma.exception-filter.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,37 @@ | ||
import { ArgumentsHost, Catch, ExceptionFilter, HttpStatus, Logger } from '@nestjs/common'; | ||
import { Prisma } from '@prisma/client'; | ||
import { Response } from 'express'; | ||
|
||
@Catch(Prisma.PrismaClientKnownRequestError) | ||
export class PrismaExceptionFilter implements ExceptionFilter<Prisma.PrismaClientKnownRequestError> { | ||
private readonly logger = new Logger(); | ||
|
||
catch(exception: Prisma.PrismaClientKnownRequestError, host: ArgumentsHost) { | ||
const ctx = host.switchToHttp(); | ||
const response = ctx.getResponse<Response>(); | ||
|
||
// Unique constraint failed. | ||
// See https://www.prisma.io/docs/orm/reference/error-reference#p2002. | ||
if (exception.code === 'P2002') { | ||
// We assume that the unique constraint was caused by the user passing a duplicate value to a unique field. | ||
return response.status(HttpStatus.UNPROCESSABLE_ENTITY).json({ | ||
message: 'Unique constraint failed', | ||
details: { | ||
fields: (exception.meta as { target: string[] }).target, | ||
}, | ||
}); | ||
} | ||
|
||
this.logger.error(exception.stack); | ||
const isDevelopment = process.env.NODE_ENV === 'development'; | ||
response.status(HttpStatus.INTERNAL_SERVER_ERROR).json({ | ||
message: 'Internal Server Error', | ||
details: isDevelopment | ||
? { | ||
code: exception.code, | ||
message: exception.message, | ||
} | ||
: undefined, | ||
}); | ||
} | ||
} |
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
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
2 changes: 1 addition & 1 deletion
2
libs/client-shared/src/lib/features/alert/alert/alert.component.html
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<progress *ngIf="progress !== null" [value]="progress" [max]="1"></progress> | ||
<svg-icon class="icon" [key]="icon"></svg-icon> | ||
<p>{{ alert.text }}</p> | ||
<p>{{ text$ | async }}</p> | ||
<svg-icon class="close" key="close"></svg-icon> |
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