error handling refactor and also added the notification/annotation error codes
This commit is contained in:
parent
a06ada47d6
commit
4932dfe9e2
|
@ -1,4 +1,5 @@
|
||||||
error-thesaurus:
|
error-thesaurus:
|
||||||
|
# common errors start with 1..
|
||||||
hash-conflict:
|
hash-conflict:
|
||||||
code: 100
|
code: 100
|
||||||
message: there is a hash conflict for the item modified. please reload to get the latest changes
|
message: there is a hash conflict for the item modified. please reload to get the latest changes
|
||||||
|
@ -11,39 +12,41 @@ error-thesaurus:
|
||||||
missing-tenant:
|
missing-tenant:
|
||||||
code: 103
|
code: 103
|
||||||
message: tenant scope not provided
|
message: tenant scope not provided
|
||||||
invalid-api-key:
|
|
||||||
code: 104
|
|
||||||
message: provided APIKey not valid
|
|
||||||
stale-api-key:
|
|
||||||
code: 105
|
|
||||||
message: there was a problem authorizing you with your API key. Please try again. Contact the system administrator if the problem persists
|
|
||||||
model-validation:
|
model-validation:
|
||||||
code: 106
|
code: 106
|
||||||
message: validation error
|
message: validation error
|
||||||
sensitive-info:
|
|
||||||
code: 107
|
|
||||||
message: you are attempting to access sensitive information. please don't do that
|
|
||||||
non-person-principal:
|
|
||||||
code: 108
|
|
||||||
message: the operation is available only to person users
|
|
||||||
blocking-consent:
|
|
||||||
code: 113
|
|
||||||
message: user consents are not sufficient to complete the operation
|
|
||||||
single-tenant-configuration-per-type-supported:
|
|
||||||
code: 116
|
|
||||||
message: a single tenant configuration entry per config type is supported
|
|
||||||
incompatible-tenant-configuration-types:
|
|
||||||
code: 117
|
|
||||||
message: the provided tenant configuration type is incompatible
|
|
||||||
missing-totp-token:
|
|
||||||
code: 118
|
|
||||||
message: totp token not provided
|
|
||||||
overlapping-tenant-configuration-notifier-list:
|
|
||||||
code: 119
|
|
||||||
message: Overlapping Tenant Configuration Notifier List
|
|
||||||
tenant-not-allowed:
|
tenant-not-allowed:
|
||||||
code: 113
|
code: 112
|
||||||
message: tenant not allowed
|
message: tenant not allowed
|
||||||
tenant-tampering:
|
tenant-tampering:
|
||||||
code: 123
|
code: 127
|
||||||
message: Tenant tampering
|
message: Tenant tampering
|
||||||
|
|
||||||
|
# annotations¬ification errors start with 2..
|
||||||
|
invalid-api-key:
|
||||||
|
code: 200
|
||||||
|
message: provided APIKey not valid
|
||||||
|
stale-api-key:
|
||||||
|
code: 201
|
||||||
|
message: there was a problem authorizing you with your API key. Please try again. Contact the system administrator if the problem persists
|
||||||
|
sensitive-info:
|
||||||
|
code: 202
|
||||||
|
message: you are attempting to access sensitive information. please don't do that
|
||||||
|
non-person-principal:
|
||||||
|
code: 203
|
||||||
|
message: the operation is available only to person users
|
||||||
|
blocking-consent:
|
||||||
|
code: 204
|
||||||
|
message: user consents are not sufficient to complete the operation
|
||||||
|
single-tenant-configuration-per-type-supported:
|
||||||
|
code: 205
|
||||||
|
message: a single tenant configuration entry per config type is supported
|
||||||
|
incompatible-tenant-configuration-types:
|
||||||
|
code: 206
|
||||||
|
message: the provided tenant configuration type is incompatible
|
||||||
|
missing-totp-token:
|
||||||
|
code: 207
|
||||||
|
message: totp token not provided
|
||||||
|
overlapping-tenant-configuration-notifier-list:
|
||||||
|
code: 208
|
||||||
|
message: Overlapping Tenant Configuration Notifier List
|
||||||
|
|
|
@ -1,29 +1,124 @@
|
||||||
|
import { TranslateService } from "@ngx-translate/core";
|
||||||
|
|
||||||
export enum ResponseErrorCode {
|
export enum ResponseErrorCode {
|
||||||
HashConflict = 100,
|
// Common Errors
|
||||||
Forbidden = 101,
|
HashConflict = 100,
|
||||||
SystemError = 102,
|
Forbidden = 101,
|
||||||
MissingTenant = 103,
|
SystemError = 102,
|
||||||
ΜodelValidation = 106,
|
MissingTenant = 103,
|
||||||
// TenantCodeRequired = 108, not used
|
ModelValidation = 106,
|
||||||
// TenantNameRequired = 109, not used
|
// TenantCodeRequired = 108, not used
|
||||||
TenantNotAllowed = 112,
|
// TenantNameRequired = 109, not used
|
||||||
DescriptionTemplateNewVersionConflict = 113,
|
TenantNotAllowed = 112,
|
||||||
DescriptionTemplateIsNotFinalized = 114,
|
DescriptionTemplateNewVersionConflict = 113,
|
||||||
MultipleDescriptionTemplateVersionsNotSupported = 115,
|
DescriptionTemplateIsNotFinalized = 114,
|
||||||
DmpNewVersionConflict = 116,
|
MultipleDescriptionTemplateVersionsNotSupported = 115,
|
||||||
DmpIsNotFinalized = 117,
|
DmpNewVersionConflict = 116,
|
||||||
MultipleDmpVersionsNotSupported = 118,
|
DmpIsNotFinalized = 117,
|
||||||
DmpIsFinalized = 119,
|
MultipleDmpVersionsNotSupported = 118,
|
||||||
DmpCanNotChange = 120,
|
DmpIsFinalized = 119,
|
||||||
DmpDescriptionTemplateCanNotChange = 121,
|
DmpCanNotChange = 120,
|
||||||
InvalidDescriptionTemplate = 122,
|
DmpDescriptionTemplateCanNotChange = 121,
|
||||||
DescriptionIsFinalized = 123,
|
InvalidDescriptionTemplate = 122,
|
||||||
DmpBlueprintHasNoDescriptionTemplates = 124,
|
DescriptionIsFinalized = 123,
|
||||||
DmpBlueprintNewVersionConflict = 125,
|
DmpBlueprintHasNoDescriptionTemplates = 124,
|
||||||
DmpDescriptionTemplateCanNotRemove = 126,
|
DmpBlueprintNewVersionConflict = 125,
|
||||||
TenantTampering = 127,
|
DmpDescriptionTemplateCanNotRemove = 126,
|
||||||
TenantConfigurationTypeCanNotChange = 128,
|
TenantTampering = 127,
|
||||||
MultipleTenantConfigurationTypeNotAllowed = 129,
|
TenantConfigurationTypeCanNotChange = 128,
|
||||||
TenantCodeExists = 130,
|
MultipleTenantConfigurationTypeNotAllowed = 129,
|
||||||
DmpNewVersionAlreadyCreatedDraft = 131
|
TenantCodeExists = 130,
|
||||||
|
DmpNewVersionAlreadyCreatedDraft = 131,
|
||||||
|
|
||||||
|
// Notification & Annotation Errors
|
||||||
|
InvalidApiKey = 200,
|
||||||
|
StaleApiKey = 201,
|
||||||
|
SensitiveInfo = 202,
|
||||||
|
NonPersonPrincipal = 203,
|
||||||
|
BlockingConsent = 204,
|
||||||
|
SingleTenantConfigurationPerTypeSupported = 205,
|
||||||
|
IncompatibleTenantConfigurationTypes = 206,
|
||||||
|
MissingTotpToken = 207,
|
||||||
|
OverlappingTenantConfigurationNotifierList = 208,
|
||||||
|
}
|
||||||
|
|
||||||
|
export class ResponseErrorCodeHelper {
|
||||||
|
public static isBackendError(statusCode: number): boolean {
|
||||||
|
return Object.values(ResponseErrorCode).includes(statusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getErrorMessageByBackendStatusCode(statusCode: number, language: TranslateService): string {
|
||||||
|
switch (statusCode) {
|
||||||
|
case ResponseErrorCode.HashConflict:
|
||||||
|
return language.instant("GENERAL.BACKEND-ERRORS.HASH-CONFLICT");
|
||||||
|
case ResponseErrorCode.Forbidden:
|
||||||
|
return language.instant("GENERAL.BACKEND-ERRORS.FORBIDDEN");
|
||||||
|
case ResponseErrorCode.SystemError:
|
||||||
|
return language.instant("GENERAL.BACKEND-ERRORS.SYSTEM-ERROR");
|
||||||
|
case ResponseErrorCode.MissingTenant:
|
||||||
|
return language.instant("GENERAL.BACKEND-ERRORS.MISSING-TENANT");
|
||||||
|
case ResponseErrorCode.ModelValidation:
|
||||||
|
return language.instant("GENERAL.BACKEND-ERRORS.MODEL-VALIDATION");
|
||||||
|
case ResponseErrorCode.TenantNotAllowed:
|
||||||
|
return language.instant("GENERAL.BACKEND-ERRORS.TENANT-NOT-ALLOWED");
|
||||||
|
case ResponseErrorCode.DescriptionTemplateNewVersionConflict:
|
||||||
|
return language.instant("GENERAL.BACKEND-ERRORS.DESCRIPTION-TEMPLATE-NEW-VERSION-CONFLICT");
|
||||||
|
case ResponseErrorCode.DescriptionTemplateIsNotFinalized:
|
||||||
|
return language.instant("GENERAL.BACKEND-ERRORS.DESCRIPTION-TEMPLATE-IS-NOT-FINALIZED");
|
||||||
|
case ResponseErrorCode.MultipleDescriptionTemplateVersionsNotSupported:
|
||||||
|
return language.instant("GENERAL.BACKEND-ERRORS.MULTIPLE-DESCRIPTION-TEMPLATE-VERSIONS-NOT-SUPPORTED");
|
||||||
|
case ResponseErrorCode.DmpNewVersionConflict:
|
||||||
|
return language.instant("GENERAL.BACKEND-ERRORS.DMP-NEW-VERSION-CONFLICT");
|
||||||
|
case ResponseErrorCode.DmpIsNotFinalized:
|
||||||
|
return language.instant("GENERAL.BACKEND-ERRORS.DMP-IS-NOT-FINALIZED");
|
||||||
|
case ResponseErrorCode.MultipleDmpVersionsNotSupported:
|
||||||
|
return language.instant("GENERAL.BACKEND-ERRORS.MULTIPLE-DMP-VERSIONS-NOT-SUPPORTED");
|
||||||
|
case ResponseErrorCode.DmpIsFinalized:
|
||||||
|
return language.instant("GENERAL.BACKEND-ERRORS.DMP-IS-FINALIZED");
|
||||||
|
case ResponseErrorCode.DmpCanNotChange:
|
||||||
|
return language.instant("GENERAL.BACKEND-ERRORS.DMP-CAN-NOT-CHANGE");
|
||||||
|
case ResponseErrorCode.DmpDescriptionTemplateCanNotChange:
|
||||||
|
return language.instant("GENERAL.BACKEND-ERRORS.DMP-DESCRIPTION-TEMPLATE-CAN-NOT-CHANGE");
|
||||||
|
case ResponseErrorCode.InvalidDescriptionTemplate:
|
||||||
|
return language.instant("GENERAL.BACKEND-ERRORS.INVALID-DESCRIPTION-TEMPLATE");
|
||||||
|
case ResponseErrorCode.DescriptionIsFinalized:
|
||||||
|
return language.instant("GENERAL.BACKEND-ERRORS.DESCRIPTION-IS-FINALIZED");
|
||||||
|
case ResponseErrorCode.DmpBlueprintHasNoDescriptionTemplates:
|
||||||
|
return language.instant("GENERAL.BACKEND-ERRORS.DMP-BLUEPRINT-HAS-NO-DESCRIPTION-TEMPLATES");
|
||||||
|
case ResponseErrorCode.DmpBlueprintNewVersionConflict:
|
||||||
|
return language.instant("GENERAL.BACKEND-ERRORS.DMP-BLUEPRINT-NEW-VERSION-CONFLICT");
|
||||||
|
case ResponseErrorCode.DmpDescriptionTemplateCanNotRemove:
|
||||||
|
return language.instant("GENERAL.BACKEND-ERRORS.DMP-DESCRIPTION-TEMPLATE-CAN-NOT-REMOVE");
|
||||||
|
case ResponseErrorCode.TenantTampering:
|
||||||
|
return language.instant("GENERAL.BACKEND-ERRORS.TENANT-TAMPERING");
|
||||||
|
case ResponseErrorCode.TenantConfigurationTypeCanNotChange:
|
||||||
|
return language.instant("GENERAL.BACKEND-ERRORS.TENANT-CONFIGURATION-TYPE-CAN-NOT-CHANGE");
|
||||||
|
case ResponseErrorCode.MultipleTenantConfigurationTypeNotAllowed:
|
||||||
|
return language.instant("GENERAL.BACKEND-ERRORS.MULTIPLE-TENANT-CONFIGURATION-TYPE-NOT-ALLOWED");
|
||||||
|
case ResponseErrorCode.TenantCodeExists:
|
||||||
|
return language.instant("GENERAL.BACKEND-ERRORS.TENANT-CODE-EXISTS");
|
||||||
|
case ResponseErrorCode.DmpNewVersionAlreadyCreatedDraft:
|
||||||
|
return language.instant("GENERAL.BACKEND-ERRORS.DMP-NEW-VERSION-ALREADY-CREATED-DRAFT");
|
||||||
|
case ResponseErrorCode.InvalidApiKey:
|
||||||
|
return language.instant("GENERAL.BACKEND-ERRORS.INVALID-API-KEY");
|
||||||
|
case ResponseErrorCode.StaleApiKey:
|
||||||
|
return language.instant("GENERAL.BACKEND-ERRORS.STALE-API-KEY");
|
||||||
|
case ResponseErrorCode.SensitiveInfo:
|
||||||
|
return language.instant("GENERAL.BACKEND-ERRORS.SENSITIVE-INFO");
|
||||||
|
case ResponseErrorCode.NonPersonPrincipal:
|
||||||
|
return language.instant("GENERAL.BACKEND-ERRORS.NON-PERSON-PRINCIPAL");
|
||||||
|
case ResponseErrorCode.BlockingConsent:
|
||||||
|
return language.instant("GENERAL.BACKEND-ERRORS.BLOCKING-CONSENT");
|
||||||
|
case ResponseErrorCode.SingleTenantConfigurationPerTypeSupported:
|
||||||
|
return language.instant("GENERAL.BACKEND-ERRORS.SINGLE-TENANT-CONFIGURATION-PER-TYPE-SUPPORTED");
|
||||||
|
case ResponseErrorCode.IncompatibleTenantConfigurationTypes:
|
||||||
|
return language.instant("GENERAL.BACKEND-ERRORS.INCOMPATIBLE-TENANT-CONFIGURATION-TYPES");
|
||||||
|
case ResponseErrorCode.MissingTotpToken:
|
||||||
|
return language.instant("GENERAL.BACKEND-ERRORS.MISSING-TOTP-TOKEN");
|
||||||
|
case ResponseErrorCode.OverlappingTenantConfigurationNotifierList:
|
||||||
|
return language.instant("GENERAL.BACKEND-ERRORS.OVERLAPPING-TENANT-CONFIGURATION-NOTIFIER-LIST");
|
||||||
|
default:
|
||||||
|
return language.instant("GENERAL.SNACK-BAR.NOT-FOUND");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ import { StartNewDescriptionDialogComponent } from '../start-new-description-dia
|
||||||
import { DmpBlueprint, DmpBlueprintDefinition, DmpBlueprintDefinitionSection } from '@app/core/model/dmp-blueprint/dmp-blueprint';
|
import { DmpBlueprint, DmpBlueprintDefinition, DmpBlueprintDefinitionSection } from '@app/core/model/dmp-blueprint/dmp-blueprint';
|
||||||
import { SortDirection } from '@common/modules/hybrid-listing/hybrid-listing.component';
|
import { SortDirection } from '@common/modules/hybrid-listing/hybrid-listing.component';
|
||||||
import { AnalyticsService } from '@app/core/services/matomo/analytics-service';
|
import { AnalyticsService } from '@app/core/services/matomo/analytics-service';
|
||||||
|
import { HttpErrorHandlingService } from '@common/modules/errors/error-handling/http-error-handling.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-description-listing-component',
|
selector: 'app-description-listing-component',
|
||||||
|
@ -104,6 +105,7 @@ export class DescriptionListingComponent extends BaseComponent implements OnInit
|
||||||
private httpClient: HttpClient,
|
private httpClient: HttpClient,
|
||||||
private analyticsService: AnalyticsService,
|
private analyticsService: AnalyticsService,
|
||||||
private fb: UntypedFormBuilder,
|
private fb: UntypedFormBuilder,
|
||||||
|
private httpErrorHandlingService: HttpErrorHandlingService,
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
@ -262,7 +264,8 @@ export class DescriptionListingComponent extends BaseComponent implements OnInit
|
||||||
if (lookup?.page?.offset === 0) this.listingItems = [];
|
if (lookup?.page?.offset === 0) this.listingItems = [];
|
||||||
this.listingItems.push(...result.items);
|
this.listingItems.push(...result.items);
|
||||||
this.hasListingItems = true;
|
this.hasListingItems = true;
|
||||||
});
|
},
|
||||||
|
(error) => this.httpErrorHandlingService.handleBackedRequestError(error));
|
||||||
}else{
|
}else{
|
||||||
this.descriptionService.query(lookup).pipe(takeUntil(this._destroyed))
|
this.descriptionService.query(lookup).pipe(takeUntil(this._destroyed))
|
||||||
.subscribe(result => {
|
.subscribe(result => {
|
||||||
|
@ -273,9 +276,9 @@ export class DescriptionListingComponent extends BaseComponent implements OnInit
|
||||||
if (description.status != DescriptionStatus.Canceled) this.listingItems.push(description);
|
if (description.status != DescriptionStatus.Canceled) this.listingItems.push(description);
|
||||||
})
|
})
|
||||||
this.hasListingItems = true;
|
this.hasListingItems = true;
|
||||||
});
|
},
|
||||||
|
(error) => this.httpErrorHandlingService.handleBackedRequestError(error));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
openFiltersDialog(): void {
|
openFiltersDialog(): void {
|
||||||
|
|
|
@ -44,9 +44,9 @@
|
||||||
"DMP-IS-NOT-FINALIZED": "The selected DMP is not finalized.",
|
"DMP-IS-NOT-FINALIZED": "The selected DMP is not finalized.",
|
||||||
"MULTIPLE-DMP-VERSIONS-NOT-SUPPORTED": "Multiple versions of the selected DMP where found. Please contact your administrator.",
|
"MULTIPLE-DMP-VERSIONS-NOT-SUPPORTED": "Multiple versions of the selected DMP where found. Please contact your administrator.",
|
||||||
"DMP-IS-FINALIZED": "The requested action cannot be completed as the DMP has been finalized. To proceed, please revert the finalization.",
|
"DMP-IS-FINALIZED": "The requested action cannot be completed as the DMP has been finalized. To proceed, please revert the finalization.",
|
||||||
"DMP-CAN-NOT-CHANGE": "While tying to update your Description, a validation error occured. You cannot modify the Description's associated DMP.",
|
"DMP-CAN-NOT-CHANGE": "While tying to update your Description, a validation error occurred. You cannot modify the Description's associated DMP.",
|
||||||
"DMP-DESCRIPTION-TEMPLATE-CAN-NOT-CHANGE": "While tying to update your Description, a validation error occured. You cannot modify the Description's associated DMP's Description Template.",
|
"DMP-DESCRIPTION-TEMPLATE-CAN-NOT-CHANGE": "While tying to update your Description, a validation error occurred. You cannot modify the Description's associated DMP's Description Template.",
|
||||||
"INVALID-DESCRIPTION-TEMPLATE": "While tying to update your Description, a validation error occured. The Description's associated DMP's Description Template is invalid.",
|
"INVALID-DESCRIPTION-TEMPLATE": "While tying to update your Description, a validation error occurred. The Description's associated DMP's Description Template is invalid.",
|
||||||
"DESCRIPTION-IS-FINALIZED": "The requested action cannot be completed as the Description has been finalized. To proceed, please revert the finalization.",
|
"DESCRIPTION-IS-FINALIZED": "The requested action cannot be completed as the Description has been finalized. To proceed, please revert the finalization.",
|
||||||
"DMP-BLUEPRINT-HAS-NO-DESCRIPTION-TEMPLATES": "You need to select at least one Description Template. Click the 'Has Description Templates' button to proceed.",
|
"DMP-BLUEPRINT-HAS-NO-DESCRIPTION-TEMPLATES": "You need to select at least one Description Template. Click the 'Has Description Templates' button to proceed.",
|
||||||
"DMP-BLUEPRINT-NEW-VERSION-CONFLICT": "While trying to update your Blueprint, a version conflict occurred. Your Blueprint is not in the latest version.",
|
"DMP-BLUEPRINT-NEW-VERSION-CONFLICT": "While trying to update your Blueprint, a version conflict occurred. Your Blueprint is not in the latest version.",
|
||||||
|
@ -55,7 +55,16 @@
|
||||||
"TENANT-CONFIGURATION-TYPE-CAN-NOT-CHANGE": "The configuration type for this Tenant cannot be changed.",
|
"TENANT-CONFIGURATION-TYPE-CAN-NOT-CHANGE": "The configuration type for this Tenant cannot be changed.",
|
||||||
"MULTIPLE-TENANT-CONFIGURATION-TYPE-NOT-ALLOWED": "Tenant Configuration already exists for this Tenant.",
|
"MULTIPLE-TENANT-CONFIGURATION-TYPE-NOT-ALLOWED": "Tenant Configuration already exists for this Tenant.",
|
||||||
"TENANT-CODE-EXISTS": "The Tenant code you provided already exists. Please choose a different code.",
|
"TENANT-CODE-EXISTS": "The Tenant code you provided already exists. Please choose a different code.",
|
||||||
"DMP-NEW-VERSION-ALREADY-CREATED-DRAFT": "You have already created a new draft version for this plan."
|
"DMP-NEW-VERSION-ALREADY-CREATED-DRAFT": "You have already created a new draft version for this plan.",
|
||||||
|
"INVALID-API-KEY": "Invalid configurations detected. Please contact your administrator.",
|
||||||
|
"STALE-API-KEY": "A problem occurred while trying to authorize you. Please try refreshing the page or logging in again. Contact the system administrator if the problem persists.",
|
||||||
|
"SENSITIVE-INFO": "You've reached a section that contains sensitive information. To protect your privacy, please head back to the public area of the site or log in with your authorized account to access this information.",
|
||||||
|
"NON-PERSON-PRINCIPAL": "The operation is unavailable. Please contact your administrator.",
|
||||||
|
"BLOCKING-CONSENT": "We cannot complete your request due to missing permissions. Please review your account settings.",
|
||||||
|
"SINGLE-TENANT-CONFIGURATION-PER-TYPE-SUPPORTED": "Could not process your request. Tenant Configuration already exists for this Tenant.",
|
||||||
|
"INCOMPATIBLE-TENANT-CONFIGURATION-TYPES": "Something went wrong while trying to update your tenant configurations. Please try again or contact your administrator.",
|
||||||
|
"MISSING-TOTP-TOKEN": "We could not process your request or the operation is unavailable. Please contact your administrator.",
|
||||||
|
"OVERLAPPING-TENANT-CONFIGURATION-NOTIFIER-LIST": "An error occurred due to overlapping configurations. Please try again or contact your administrator."
|
||||||
},
|
},
|
||||||
"FORM-VALIDATION-DISPLAY-DIALOG": {
|
"FORM-VALIDATION-DISPLAY-DIALOG": {
|
||||||
"WARNING": "Warning!",
|
"WARNING": "Warning!",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { HttpErrorResponse } from '@angular/common/http';
|
import { HttpErrorResponse } from '@angular/common/http';
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { ResponseErrorCode } from '@app/core/common/enum/respone-error-code';
|
import { ResponseErrorCode, ResponseErrorCodeHelper } from '@app/core/common/enum/respone-error-code';
|
||||||
import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service';
|
import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
|
||||||
|
@ -16,82 +16,10 @@ export class HttpErrorHandlingService {
|
||||||
const error: HttpError = this.getError(errorResponse);
|
const error: HttpError = this.getError(errorResponse);
|
||||||
let errorMessage = messageOvverrides?.has(error.statusCode) ? messageOvverrides?.get(error.statusCode) : null;
|
let errorMessage = messageOvverrides?.has(error.statusCode) ? messageOvverrides?.get(error.statusCode) : null;
|
||||||
|
|
||||||
if(errorResponse.error.code === ResponseErrorCode.HashConflict){
|
if(errorResponse.error && ResponseErrorCodeHelper.isBackendError(errorResponse.error?.code)){
|
||||||
this.uiNotificationService.snackBarNotification(this.language.instant("GENERAL.BACKEND-ERRORS.HASH-CONFLICT"), SnackBarNotificationLevel.Error);
|
this.uiNotificationService.snackBarNotification(ResponseErrorCodeHelper.getErrorMessageByBackendStatusCode(errorResponse.error.code, this.language), SnackBarNotificationLevel.Error);
|
||||||
}
|
}
|
||||||
else if(errorResponse.error.code === ResponseErrorCode.Forbidden){
|
else if (error.statusCode === 302 || error.statusCode === 400 || error.statusCode === 403 || error.statusCode === 404) {
|
||||||
this.uiNotificationService.snackBarNotification(this.language.instant("GENERAL.BACKEND-ERRORS.FORBIDDEN"), SnackBarNotificationLevel.Error);
|
|
||||||
}
|
|
||||||
else if(errorResponse.error.code === ResponseErrorCode.SystemError){
|
|
||||||
this.uiNotificationService.snackBarNotification(this.language.instant("GENERAL.BACKEND-ERRORS.SYSTEM-ERROR"), SnackBarNotificationLevel.Error);
|
|
||||||
}
|
|
||||||
else if(errorResponse.error.code === ResponseErrorCode.MissingTenant){
|
|
||||||
this.uiNotificationService.snackBarNotification(this.language.instant("GENERAL.BACKEND-ERRORS.MISSING-TENANT"), SnackBarNotificationLevel.Error);
|
|
||||||
}
|
|
||||||
else if(errorResponse.error.code === ResponseErrorCode.ΜodelValidation){
|
|
||||||
this.uiNotificationService.snackBarNotification(this.language.instant("GENERAL.BACKEND-ERRORS.MODEL-VALIDATION"), SnackBarNotificationLevel.Error);
|
|
||||||
}
|
|
||||||
else if(errorResponse.error.code === ResponseErrorCode.TenantNotAllowed){
|
|
||||||
this.uiNotificationService.snackBarNotification(this.language.instant("GENERAL.BACKEND-ERRORS.TENANT-NOT-ALLOWED"), SnackBarNotificationLevel.Error);
|
|
||||||
}
|
|
||||||
else if(errorResponse.error.code === ResponseErrorCode.DescriptionTemplateNewVersionConflict){
|
|
||||||
this.uiNotificationService.snackBarNotification(this.language.instant("GENERAL.BACKEND-ERRORS.DESCRIPTION-TEMPLATE-NEW-VERSION-CONFLICT"), SnackBarNotificationLevel.Error);
|
|
||||||
}
|
|
||||||
else if(errorResponse.error.code === ResponseErrorCode.DescriptionTemplateIsNotFinalized){
|
|
||||||
this.uiNotificationService.snackBarNotification(this.language.instant("GENERAL.BACKEND-ERRORS.DESCRIPTION-TEMPLATE-IS-NOT-FINALIZED"), SnackBarNotificationLevel.Error);
|
|
||||||
}
|
|
||||||
else if(errorResponse.error.code === ResponseErrorCode.MultipleDescriptionTemplateVersionsNotSupported){
|
|
||||||
this.uiNotificationService.snackBarNotification(this.language.instant("GENERAL.BACKEND-ERRORS.MULTIPLE-DESCRIPTION-TEMPLATE-VERSIONS-NOT-SUPPORTED"), SnackBarNotificationLevel.Error);
|
|
||||||
}
|
|
||||||
else if(errorResponse.error.code === ResponseErrorCode.DmpNewVersionConflict){
|
|
||||||
this.uiNotificationService.snackBarNotification(this.language.instant("GENERAL.BACKEND-ERRORS.DMP-NEW-VERSION-CONFLICT"), SnackBarNotificationLevel.Error);
|
|
||||||
}
|
|
||||||
else if(errorResponse.error.code === ResponseErrorCode.DmpIsNotFinalized){
|
|
||||||
this.uiNotificationService.snackBarNotification(this.language.instant("GENERAL.BACKEND-ERRORS.DMP-IS-NOT-FINALIZED"), SnackBarNotificationLevel.Error);
|
|
||||||
}
|
|
||||||
else if(errorResponse.error.code === ResponseErrorCode.MultipleDmpVersionsNotSupported){
|
|
||||||
this.uiNotificationService.snackBarNotification(this.language.instant("GENERAL.BACKEND-ERRORS.MULTIPLE-DMP-VERSIONS-NOT-SUPPORTED"), SnackBarNotificationLevel.Error);
|
|
||||||
}
|
|
||||||
else if(errorResponse.error.code === ResponseErrorCode.DmpIsFinalized){
|
|
||||||
this.uiNotificationService.snackBarNotification(this.language.instant("GENERAL.BACKEND-ERRORS.DMP-IS-FINALIZED"), SnackBarNotificationLevel.Error);
|
|
||||||
}
|
|
||||||
else if(errorResponse.error.code === ResponseErrorCode.DmpCanNotChange){
|
|
||||||
this.uiNotificationService.snackBarNotification(this.language.instant("GENERAL.BACKEND-ERRORS.DMP-CAN-NOT-CHANGE"), SnackBarNotificationLevel.Error);
|
|
||||||
}
|
|
||||||
else if(errorResponse.error.code === ResponseErrorCode.DmpDescriptionTemplateCanNotChange){
|
|
||||||
this.uiNotificationService.snackBarNotification(this.language.instant("GENERAL.BACKEND-ERRORS.DMP-DESCRIPTION-TEMPLATE-CAN-NOT-CHANGE"), SnackBarNotificationLevel.Error);
|
|
||||||
}
|
|
||||||
else if(errorResponse.error.code === ResponseErrorCode.InvalidDescriptionTemplate){
|
|
||||||
this.uiNotificationService.snackBarNotification(this.language.instant("GENERAL.BACKEND-ERRORS.INVALID-DESCRIPTION-TEMPLATE"), SnackBarNotificationLevel.Error);
|
|
||||||
}
|
|
||||||
else if(errorResponse.error.code === ResponseErrorCode.DescriptionIsFinalized){
|
|
||||||
this.uiNotificationService.snackBarNotification(this.language.instant("GENERAL.BACKEND-ERRORS.DESCRIPTION-IS-FINALIZED"), SnackBarNotificationLevel.Error);
|
|
||||||
}
|
|
||||||
else if(errorResponse.error.code === ResponseErrorCode.DmpBlueprintHasNoDescriptionTemplates){
|
|
||||||
this.uiNotificationService.snackBarNotification(this.language.instant("GENERAL.BACKEND-ERRORS.DMP-BLUEPRINT-HAS-NO-DESCRIPTION-TEMPLATES"), SnackBarNotificationLevel.Error);
|
|
||||||
}
|
|
||||||
else if(errorResponse.error.code === ResponseErrorCode.DmpBlueprintNewVersionConflict){
|
|
||||||
this.uiNotificationService.snackBarNotification(this.language.instant("GENERAL.BACKEND-ERRORS.DMP-BLUEPRINT-NEW-VERSION-CONFLICT"), SnackBarNotificationLevel.Error);
|
|
||||||
}
|
|
||||||
else if(errorResponse.error.code === ResponseErrorCode.DmpDescriptionTemplateCanNotRemove){
|
|
||||||
this.uiNotificationService.snackBarNotification(this.language.instant("GENERAL.BACKEND-ERRORS.DMP-DESCRIPTION-TEMPLATE-CAN-NOT-REMOVE"), SnackBarNotificationLevel.Error);
|
|
||||||
}
|
|
||||||
else if(errorResponse.error.code === ResponseErrorCode.TenantTampering){
|
|
||||||
this.uiNotificationService.snackBarNotification(this.language.instant("GENERAL.BACKEND-ERRORS.TENANT-TAMPERING"), SnackBarNotificationLevel.Error);
|
|
||||||
}
|
|
||||||
else if(errorResponse.error.code === ResponseErrorCode.TenantConfigurationTypeCanNotChange){
|
|
||||||
this.uiNotificationService.snackBarNotification(this.language.instant("GENERAL.BACKEND-ERRORS.TENANT-CONFIGURATION-TYPE-CAN-NOT-CHANGE"), SnackBarNotificationLevel.Error);
|
|
||||||
}
|
|
||||||
else if(errorResponse.error.code === ResponseErrorCode.MultipleTenantConfigurationTypeNotAllowed){
|
|
||||||
this.uiNotificationService.snackBarNotification(this.language.instant("GENERAL.BACKEND-ERRORS.MULTIPLE-TENANT-CONFIGURATION-TYPE-NOT-ALLOWED"), SnackBarNotificationLevel.Error);
|
|
||||||
}
|
|
||||||
else if(errorResponse.error.code === ResponseErrorCode.TenantCodeExists){
|
|
||||||
this.uiNotificationService.snackBarNotification(this.language.instant("GENERAL.BACKEND-ERRORS.TENANT-CODE-EXISTS"), SnackBarNotificationLevel.Error);
|
|
||||||
}
|
|
||||||
else if(errorResponse.error.code === ResponseErrorCode.DmpNewVersionAlreadyCreatedDraft){
|
|
||||||
this.uiNotificationService.snackBarNotification(this.language.instant("GENERAL.BACKEND-ERRORS.DMP-NEW-VERSION-ALREADY-CREATED-DRAFT"), SnackBarNotificationLevel.Error);
|
|
||||||
}
|
|
||||||
else if (error.statusCode === 302 || error.statusCode === 400 || error.statusCode === 404) {
|
|
||||||
errorMessage ??= this.language.instant('GENERAL.SNACK-BAR.NOT-FOUND');
|
errorMessage ??= this.language.instant('GENERAL.SNACK-BAR.NOT-FOUND');
|
||||||
this.uiNotificationService.snackBarNotification(errorMessage, SnackBarNotificationLevel.Warning);
|
this.uiNotificationService.snackBarNotification(errorMessage, SnackBarNotificationLevel.Warning);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
error-thesaurus:
|
error-thesaurus:
|
||||||
|
# common errors start with 1..
|
||||||
hash-conflict:
|
hash-conflict:
|
||||||
code: 100
|
code: 100
|
||||||
message: there is a hash conflict for the item modified. please reload to get the latest changes
|
message: there is a hash conflict for the item modified. please reload to get the latest changes
|
||||||
|
@ -11,45 +12,48 @@ error-thesaurus:
|
||||||
missing-tenant:
|
missing-tenant:
|
||||||
code: 103
|
code: 103
|
||||||
message: tenant scope not provided
|
message: tenant scope not provided
|
||||||
invalid-api-key:
|
|
||||||
code: 104
|
|
||||||
message: provided APIKey not valid
|
|
||||||
stale-api-key:
|
|
||||||
code: 105
|
|
||||||
message: there was a problem authorizing you with your API key. Please try again. Contact the system administrator if the problem persists
|
|
||||||
model-validation:
|
model-validation:
|
||||||
code: 106
|
code: 106
|
||||||
message: validation error
|
message: validation error
|
||||||
sensitive-info:
|
|
||||||
code: 107
|
|
||||||
message: you are attempting to access sensitive information. please don't do that
|
|
||||||
non-person-principal:
|
|
||||||
code: 108
|
|
||||||
message: the operation is available only to person users
|
|
||||||
tenant-not-allowed:
|
tenant-not-allowed:
|
||||||
code: 113
|
code: 112
|
||||||
message: tenant not allowed
|
message: tenant not allowed
|
||||||
blocking-consent:
|
|
||||||
code: 114
|
|
||||||
message: user consents are not sufficient to complete the operation
|
|
||||||
single-tenant-configuration-per-type-supported:
|
|
||||||
code: 116
|
|
||||||
message: a single tenant configuration entry per config type is supported
|
|
||||||
incompatible-tenant-configuration-types:
|
|
||||||
code: 117
|
|
||||||
message: the provided tenant configuration type is incompatible
|
|
||||||
missing-totp-token:
|
|
||||||
code: 118
|
|
||||||
message: totp token not provided
|
|
||||||
overlapping-tenant-configuration-notifier-list:
|
|
||||||
code: 119
|
|
||||||
message: Overlapping Tenant Configuration Notifier List
|
|
||||||
tenant-tampering:
|
tenant-tampering:
|
||||||
code: 123
|
code: 127
|
||||||
message: Tenant tampering
|
message: Tenant tampering
|
||||||
tenant-configuration-type-can-not-change:
|
tenant-configuration-type-can-not-change:
|
||||||
code: 124
|
code: 128
|
||||||
message: Tenant configuration type can not change
|
message: Tenant configuration type can not change
|
||||||
multiple-tenant-configuration-type-not-allowed:
|
multiple-tenant-configuration-type-not-allowed:
|
||||||
code: 125
|
code: 129
|
||||||
message: Multiple Tenant Configuration Type Not Allowed
|
message: Multiple Tenant Configuration Type Not Allowed
|
||||||
|
|
||||||
|
# annotations¬ification errors start with 2..
|
||||||
|
invalid-api-key:
|
||||||
|
code: 200
|
||||||
|
message: provided APIKey not valid
|
||||||
|
stale-api-key:
|
||||||
|
code: 201
|
||||||
|
message: there was a problem authorizing you with your API key. Please try again. Contact the system administrator if the problem persists
|
||||||
|
sensitive-info:
|
||||||
|
code: 202
|
||||||
|
message: you are attempting to access sensitive information. please don't do that
|
||||||
|
non-person-principal:
|
||||||
|
code: 203
|
||||||
|
message: the operation is available only to person users
|
||||||
|
blocking-consent:
|
||||||
|
code: 204
|
||||||
|
message: user consents are not sufficient to complete the operation
|
||||||
|
single-tenant-configuration-per-type-supported:
|
||||||
|
code: 205
|
||||||
|
message: a single tenant configuration entry per config type is supported
|
||||||
|
incompatible-tenant-configuration-types:
|
||||||
|
code: 206
|
||||||
|
message: the provided tenant configuration type is incompatible
|
||||||
|
missing-totp-token:
|
||||||
|
code: 207
|
||||||
|
message: totp token not provided
|
||||||
|
overlapping-tenant-configuration-notifier-list:
|
||||||
|
code: 208
|
||||||
|
message: Overlapping Tenant Configuration Notifier List
|
||||||
|
|
Loading…
Reference in New Issue