Skip to content

Commit 0eb621b

Browse files
authored
fix(error): improve the current error handler in DSP-APP (DSP-1911) (#540)
* chore(error): use correct error status values * chore(error): better js-lib error message handling * chore(error): better error handler * test(error): fix error handler
1 parent 67a52a3 commit 0eb621b

3 files changed

Lines changed: 16 additions & 6 deletions

File tree

‎src/app/main/error/error-handler.service.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,13 @@ export class ErrorHandlerService {
1919
) { }
2020

2121
showMessage(error: ApiResponseError) {
22+
2223
// in case of (internal) server error
23-
if (error.status === 0 || (error.status > 499 && error.status < 600)) {
24-
const status = (error.status === 0 ? 503 : error.status);
24+
const apiServerError = (error.error && error.error['response'] && error.error['response'] === null);
25+
26+
if ((error.status > 499 && error.status < 600) || apiServerError) {
27+
28+
const status = (apiServerError ? 503 : error.status);
2529

2630
// open error message in full size view
2731
const dialogConfig: MatDialogConfig = {

‎src/app/main/services/notification.service.ts‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,19 @@ export class NotificationService {
1717
// action: string = 'x', duration: number = 4200
1818
// and / or type: 'note' | 'warning' | 'error' | 'success'; which can be used for the panelClass
1919
openSnackBar(notification: string | ApiResponseError): void {
20-
const duration = 5000;
20+
let duration = 5000;
2121
let message: string;
2222
let panelClass: string;
2323

2424
if (notification instanceof ApiResponseError) {
25-
const status = (notification.status === 0 ? 503 : notification.status);
26-
const defaultStatusMsg = this._statusMsg.default;
27-
message = `${defaultStatusMsg[status].message} (${status}): ${defaultStatusMsg[status].description}`;
25+
if (notification.error && !notification.error['message'].startsWith('ajax error')) {
26+
// the Api response error contains a complex error message from dsp-js-lib
27+
message = notification.error['message'];
28+
duration = undefined;
29+
} else {
30+
const defaultStatusMsg = this._statusMsg.default;
31+
message = `${defaultStatusMsg[notification.status].message} (${notification.status}): ${defaultStatusMsg[notification.status].description}`;
32+
}
2833
panelClass = 'error';
2934
} else {
3035
message = notification;

‎src/app/workspace/resource/resource.component.html‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
<p>Reasons:</p>
7777
<ul>
7878
<li>It could be a deleted resource and does not exist anymore.</li>
79+
<li>You don't have the permissions to open this resource.</li>
7980
<li>The identifier or the ARK URL is wrong.</li>
8081
</ul>
8182
</div>

0 commit comments

Comments
 (0)