Skip to content
Permalink
Browse files
feat(error): handle 504 timeout error with snackbar (DEV-751) (#739)
  • Loading branch information
kilchenmann committed May 16, 2022
1 parent 52f904b commit 8f6c4092f12e53e6a831968b1fd451c0bec30d9b
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 12 deletions.
@@ -27,7 +27,7 @@ export class ErrorHandlerService {

const apiResponseMessage = (error.error['response'] ? error.error['response'].error : undefined);

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

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

@@ -22,18 +22,27 @@ export class NotificationService {
let panelClass: string;

if (notification instanceof ApiResponseError) {
panelClass = type ? type : 'error';
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}`;
message = `${defaultStatusMsg[notification.status].message} (${notification.status}): `;

if (notification.status === 504) {
message += `There was a timeout issue with one or several requests.
The resource(s) or a part of it cannot be displayed correctly.
Failed on ${notification.url}`;
duration = undefined;
} else {
message += `${defaultStatusMsg[notification.status].description}`;
}
}
panelClass = type ? type : 'error';
} else {
message = notification;
panelClass = type ? type : 'success';
message = notification;
}

this._snackBar.open(message, 'x', {
@@ -12,13 +12,17 @@ import {
import {
ApiResponseError,
Constants,
CountQueryResponse, IHasPropertyWithPropertyDefinition,
CountQueryResponse,
IHasPropertyWithPropertyDefinition,
KnoraApiConnection,
ReadArchiveFileValue,
ReadAudioFileValue,
ReadDocumentFileValue, ReadMovingImageFileValue, ReadResource,
ReadDocumentFileValue,
ReadMovingImageFileValue,
ReadResource,
ReadResourceSequence,
ReadStillImageFileValue, SystemPropertyDefinition
ReadStillImageFileValue,
SystemPropertyDefinition
} from '@dasch-swiss/dsp-js';
import { Subscription } from 'rxjs';
import { DspApiConnectionToken } from 'src/app/main/declarations/dsp-api-tokens';
@@ -134,8 +138,6 @@ export class ResourceComponent implements OnInit, OnChanges, OnDestroy {
}

if (event instanceof NavigationError) {
// hide loading indicator

// present error to user
this._errorHandler.showMessage(event.error);

@@ -270,6 +272,7 @@ export class ResourceComponent implements OnInit, OnChanges, OnDestroy {
}
},
(error: ApiResponseError) => {
this.loading = false;
this._errorHandler.showMessage(error);
}
);
@@ -294,7 +297,6 @@ export class ResourceComponent implements OnInit, OnChanges, OnDestroy {
} else {
this._errorHandler.showMessage(error);
}

}
);
}
@@ -103,6 +103,7 @@ export class ListViewComponent implements OnChanges {
this.pageEvent = new PageEvent();
this.pageEvent.pageIndex = 0;
this.resources = undefined;
this.emitSelectedResources();

this._doSearch();
}
@@ -159,6 +160,7 @@ export class ListViewComponent implements OnChanges {
},
(countError: ApiResponseError) => {
this._errorHandler.showMessage(countError);
this.loading = countError.status !== 504;
}
);
}
@@ -200,6 +202,7 @@ export class ListViewComponent implements OnChanges {
},
(countError: ApiResponseError) => {
this._errorHandler.showMessage(countError);
this.loading = countError.status !== 504;
}
);
}
@@ -26,9 +26,8 @@ import {
} from '@dasch-swiss/dsp-js';
import { Subscription } from 'rxjs';
import { DspApiConnectionToken } from 'src/app/main/declarations/dsp-api-tokens';
import { ErrorHandlerService } from 'src/app/main/services/error-handler.service';
import { ComponentCommunicationEventService, Events } from 'src/app/main/services/component-communication-event.service';
import { NotificationService } from 'src/app/main/services/notification.service';
import { ErrorHandlerService } from 'src/app/main/services/error-handler.service';
import { SortingService } from 'src/app/main/services/sorting.service';
import { SearchParams } from '../../results/list-view/list-view.component';

0 comments on commit 8f6c409

Please sign in to comment.