diff --git a/lib/core/i18n/en.json b/lib/core/i18n/en.json index 243c197156..a8169edac3 100644 --- a/lib/core/i18n/en.json +++ b/lib/core/i18n/en.json @@ -334,6 +334,36 @@ "RETURN_BUTTON": { "TEXT": "Back to home" } + }, + "500": { + "TITLE": "An error occurred.", + "DESCRIPTION": "Internal server error, try again or contact IT support [500].", + "SECONDARY_BUTTON": { + "TEXT": "" + }, + "RETURN_BUTTON": { + "TEXT": "Back to home" + } + }, + "502": { + "TITLE": "An error occurred.", + "DESCRIPTION": "Bad Gateway, try again or contact IT support [502].", + "SECONDARY_BUTTON": { + "TEXT": "" + }, + "RETURN_BUTTON": { + "TEXT": "Back to home" + } + }, + "504": { + "TITLE": "An error occurred.", + "DESCRIPTION": "The server timed out, try again or contact IT support [504].", + "SECONDARY_BUTTON": { + "TEXT": "" + }, + "RETURN_BUTTON": { + "TEXT": "Back to home" + } } }, "ABOUT": { diff --git a/lib/core/templates/error-content/error-content.component.spec.ts b/lib/core/templates/error-content/error-content.component.spec.ts index c3367610fa..d1b6206408 100644 --- a/lib/core/templates/error-content/error-content.component.spec.ts +++ b/lib/core/templates/error-content/error-content.component.spec.ts @@ -141,7 +141,7 @@ describe('ErrorContentComponent', () => { }); it('should navigate to an error given by the route params', async(() => { - spyOn(translateService, 'get').and.returnValue(of('404')); + spyOn(translateService, 'instant').and.returnValue(of('404')); fixture.detectChanges(); fixture.whenStable().then(() => { expect(errorContentComponent.errorCode).toBe('404'); diff --git a/lib/core/templates/error-content/error-content.component.ts b/lib/core/templates/error-content/error-content.component.ts index b1b7cfa534..c37066691f 100644 --- a/lib/core/templates/error-content/error-content.component.ts +++ b/lib/core/templates/error-content/error-content.component.ts @@ -36,6 +36,8 @@ import { TranslationService } from '../../services/translation.service'; }) export class ErrorContentComponent implements OnInit, AfterContentChecked { + static UNKNOWN_ERROR = 'UNKNOWN'; + /** Target URL for the secondary button. */ @Input() secondaryButtonUrl: string = 'report-issue'; @@ -46,7 +48,7 @@ export class ErrorContentComponent implements OnInit, AfterContentChecked { /** Error code associated with this error. */ @Input() - errorCode: string = 'UNKNOWN'; + errorCode: string = ErrorContentComponent.UNKNOWN_ERROR; hasSecondButton: boolean; @@ -59,12 +61,17 @@ export class ErrorContentComponent implements OnInit, AfterContentChecked { if (this.route) { this.route.params.forEach((params: Params) => { if (params['id']) { - this.errorCode = params['id']; + this.errorCode = this.checkErrorExists(params['id']) ? params['id'] : ErrorContentComponent.UNKNOWN_ERROR; } }); } } + checkErrorExists(errorCode: string ) { + const errorMessage = this.translateService.instant('ERROR_CONTENT.' + errorCode); + return errorMessage !== ('ERROR_CONTENT.' + errorCode); + } + getTranslations() { this.hasSecondButton = this.translateService.instant( 'ERROR_CONTENT.' + this.errorCode + '.SECONDARY_BUTTON.TEXT') ? true : false;