Browse Source

refactor: use constant for localizations instead of strings

pull/5124/head
mehmet-erim 6 years ago
parent
commit
fc673d48cb
  1. 27
      npm/ng-packs/packages/theme-shared/src/lib/handlers/error.handler.ts

27
npm/ng-packs/packages/theme-shared/src/lib/handlers/error.handler.ts

@ -87,7 +87,10 @@ export class ErrorHandler {
private listenToRouterError() { private listenToRouterError() {
this.actions this.actions
.pipe(ofActionSuccessful(RouterError), filter(this.filterRouteErrors)) .pipe(
ofActionSuccessful(RouterError),
filter(this.filterRouteErrors),
)
.subscribe(() => this.show404Page()); .subscribe(() => this.show404Page());
} }
@ -131,11 +134,11 @@ export class ErrorHandler {
? this.show401Page() ? this.show401Page()
: this.showError( : this.showError(
{ {
key: 'AbpAccount::DefaultErrorMessage401', key: DEFAULT_ERROR_LOCALIZATIONS.defaultError401.title,
defaultValue: DEFAULT_ERROR_MESSAGES.defaultError401.title, defaultValue: DEFAULT_ERROR_MESSAGES.defaultError401.title,
}, },
{ {
key: 'AbpAccount::DefaultErrorMessage401Detail', key: DEFAULT_ERROR_LOCALIZATIONS.defaultError401.details,
defaultValue: DEFAULT_ERROR_MESSAGES.defaultError401.details, defaultValue: DEFAULT_ERROR_MESSAGES.defaultError401.details,
}, },
).subscribe(() => this.navigateToLogin()); ).subscribe(() => this.navigateToLogin());
@ -143,11 +146,11 @@ export class ErrorHandler {
case 403: case 403:
this.createErrorComponent({ this.createErrorComponent({
title: { title: {
key: 'AbpAccount::DefaultErrorMessage403', key: DEFAULT_ERROR_LOCALIZATIONS.defaultError403.title,
defaultValue: DEFAULT_ERROR_MESSAGES.defaultError403.title, defaultValue: DEFAULT_ERROR_MESSAGES.defaultError403.title,
}, },
details: { details: {
key: 'AbpAccount::DefaultErrorMessage403Detail', key: DEFAULT_ERROR_LOCALIZATIONS.defaultError403.details,
defaultValue: DEFAULT_ERROR_MESSAGES.defaultError403.details, defaultValue: DEFAULT_ERROR_MESSAGES.defaultError403.details,
}, },
status: 403, status: 403,
@ -158,11 +161,11 @@ export class ErrorHandler {
? this.show404Page() ? this.show404Page()
: this.showError( : this.showError(
{ {
key: 'AbpAccount::DefaultErrorMessage404', key: DEFAULT_ERROR_LOCALIZATIONS.defaultError404.details,
defaultValue: DEFAULT_ERROR_MESSAGES.defaultError404.details, defaultValue: DEFAULT_ERROR_MESSAGES.defaultError404.details,
}, },
{ {
key: 'AbpAccount::DefaultErrorMessage404Detail', key: DEFAULT_ERROR_LOCALIZATIONS.defaultError404.title,
defaultValue: DEFAULT_ERROR_MESSAGES.defaultError404.title, defaultValue: DEFAULT_ERROR_MESSAGES.defaultError404.title,
}, },
); );
@ -170,11 +173,11 @@ export class ErrorHandler {
case 500: case 500:
this.createErrorComponent({ this.createErrorComponent({
title: { title: {
key: 'AbpAccount::500Message', key: DEFAULT_ERROR_LOCALIZATIONS.defaultError500.title,
defaultValue: DEFAULT_ERROR_MESSAGES.defaultError500.title, defaultValue: DEFAULT_ERROR_MESSAGES.defaultError500.title,
}, },
details: { details: {
key: 'AbpAccount::InternalServerErrorMessage', key: DEFAULT_ERROR_LOCALIZATIONS.defaultError500.details,
defaultValue: DEFAULT_ERROR_MESSAGES.defaultError500.details, defaultValue: DEFAULT_ERROR_MESSAGES.defaultError500.details,
}, },
status: 500, status: 500,
@ -184,7 +187,7 @@ export class ErrorHandler {
if (err.statusText === 'Unknown Error') { if (err.statusText === 'Unknown Error') {
this.createErrorComponent({ this.createErrorComponent({
title: { title: {
key: 'AbpAccount::DefaultErrorMessage', key: DEFAULT_ERROR_LOCALIZATIONS.defaultError.title,
defaultValue: DEFAULT_ERROR_MESSAGES.defaultError.title, defaultValue: DEFAULT_ERROR_MESSAGES.defaultError.title,
}, },
details: err.message, details: err.message,
@ -212,7 +215,7 @@ export class ErrorHandler {
private show401Page() { private show401Page() {
this.createErrorComponent({ this.createErrorComponent({
title: { title: {
key: 'AbpAccount::401Message', key: DEFAULT_ERROR_LOCALIZATIONS.defaultError401.title,
defaultValue: DEFAULT_ERROR_MESSAGES.defaultError401.title, defaultValue: DEFAULT_ERROR_MESSAGES.defaultError401.title,
}, },
status: 401, status: 401,
@ -222,7 +225,7 @@ export class ErrorHandler {
private show404Page() { private show404Page() {
this.createErrorComponent({ this.createErrorComponent({
title: { title: {
key: 'AbpAccount::404Message', key: DEFAULT_ERROR_LOCALIZATIONS.defaultError404.title,
defaultValue: DEFAULT_ERROR_MESSAGES.defaultError404.title, defaultValue: DEFAULT_ERROR_MESSAGES.defaultError404.title,
}, },
status: 404, status: 404,

Loading…
Cancel
Save