Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(error): improve the current error handler in DSP-APP (DSP-1911) #540

Merged
merged 5 commits into from Sep 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/app/main/error/error-handler.service.ts
Expand Up @@ -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 = {
Expand Down
13 changes: 9 additions & 4 deletions src/app/main/services/notification.service.ts
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/app/workspace/resource/resource.component.html
Expand Up @@ -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>
Expand Down