Skip to content
Permalink
Browse files
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
  • Loading branch information
kilchenmann committed Sep 22, 2021
1 parent 67a52a3 commit 0eb621bbf9aa182d17b09df3ead46c34d357e0e5
Showing with 16 additions and 6 deletions.
  1. +6 −2 src/app/main/error/error-handler.service.ts
  2. +9 −4 src/app/main/services/notification.service.ts
  3. +1 −0 src/app/workspace/resource/resource.component.html
@@ -19,9 +19,13 @@ export class ErrorHandlerService {
) { }

showMessage(error: ApiResponseError) {

// in case of (internal) server error
if (error.status === 0 || (error.status > 499 && error.status < 600)) {
const status = (error.status === 0 ? 503 : error.status);
const apiServerError = (error.error && error.error['response'] && error.error['response'] === null);

if ((error.status > 499 && error.status < 600) || apiServerError) {

const status = (apiServerError ? 503 : error.status);

// open error message in full size view
const dialogConfig: MatDialogConfig = {
@@ -17,14 +17,19 @@ export class NotificationService {
// action: string = 'x', duration: number = 4200
// and / or type: 'note' | 'warning' | 'error' | 'success'; which can be used for the panelClass
openSnackBar(notification: string | ApiResponseError): void {
const duration = 5000;
let duration = 5000;
let message: string;
let panelClass: string;

if (notification instanceof ApiResponseError) {
const status = (notification.status === 0 ? 503 : notification.status);
const defaultStatusMsg = this._statusMsg.default;
message = `${defaultStatusMsg[status].message} (${status}): ${defaultStatusMsg[status].description}`;
if (notification.error && !notification.error['message'].startsWith('ajax error')) {
// the Api response error contains a complex error message from dsp-js-lib
message = notification.error['message'];
duration = undefined;
} else {
const defaultStatusMsg = this._statusMsg.default;
message = `${defaultStatusMsg[notification.status].message} (${notification.status}): ${defaultStatusMsg[notification.status].description}`;
}
panelClass = 'error';
} else {
message = notification;
@@ -76,6 +76,7 @@
<p>Reasons:</p>
<ul>
<li>It could be a deleted resource and does not exist anymore.</li>
<li>You don't have the permissions to open this resource.</li>
<li>The identifier or the ARK URL is wrong.</li>
</ul>
</div>

0 comments on commit 0eb621b

Please sign in to comment.