Merge branch 'uate' of https://git.lincpay.tech/CBSNexora/cbsnexora into uate
This commit is contained in:
@@ -21,6 +21,7 @@ import { environment } from '../../../environments/environment';
|
||||
import { Logger } from '../logger/logger.service';
|
||||
import { AlertService } from '../alert/alert.service';
|
||||
import { TranslateService } from '@ngx-translate/core'; // Added import for TranslateService
|
||||
import { SILENT_HTTP_ERROR } from './silent-error.token';
|
||||
|
||||
/** Initialize Logger */
|
||||
const log = new Logger('ErrorHandlerInterceptor');
|
||||
@@ -57,13 +58,30 @@ export class ErrorHandlerInterceptor implements HttpInterceptor {
|
||||
// "No pending edit for this client" is the normal/expected state — checked on every edit-page
|
||||
// load, not a real error the user needs to see.
|
||||
const isClientPendingEditRequest = request.url.match(/\/clients\/\d+\/edit\/pending$/);
|
||||
// Risk rules are an enhancement on top of a default risk-category fallback — if this
|
||||
// endpoint isn't available on a given backend deployment, the client-general-step
|
||||
// component already falls back to riskRules = [] silently; no toast needed here either.
|
||||
const isKycRiskRulesRequest = request.url.includes('/kyc/risk-rules');
|
||||
const isSilentRequest =
|
||||
isClientImageRequest || isClientKycRequest || isDirectorRequest || isClientPendingEditRequest;
|
||||
isClientImageRequest ||
|
||||
isClientKycRequest ||
|
||||
isDirectorRequest ||
|
||||
isClientPendingEditRequest ||
|
||||
isKycRiskRulesRequest;
|
||||
|
||||
if (!environment.production && !isSilentRequest) {
|
||||
// Explicit per-request opt-out (e.g. per-row enrichment fetches on a list page whose
|
||||
// component already recovers via its own catchError) — silenced for every status, since
|
||||
// the caller took responsibility for handling failure when it set this.
|
||||
const isSilentOverride = request.context.get(SILENT_HTTP_ERROR);
|
||||
|
||||
if (!environment.production && !isSilentRequest && !isSilentOverride) {
|
||||
log.error(`Request Error: ${errorMessage}`);
|
||||
}
|
||||
|
||||
if (isSilentOverride) {
|
||||
throw response;
|
||||
}
|
||||
|
||||
// Silently handle expected 403/404 errors (no image, no KYC record)
|
||||
// Throw instead of EMPTY so component-level catchError can handle it
|
||||
if (isSilentRequest && (status === 403 || status === 404)) {
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Copyright since 2025 Mifos Initiative
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
import { HttpContextToken } from '@angular/common/http';
|
||||
|
||||
/**
|
||||
* Per-request opt-out of ErrorHandlerInterceptor's toast. Set via
|
||||
* `{ context: new HttpContext().set(SILENT_HTTP_ERROR, true) }` on calls whose caller already
|
||||
* handles failures itself (e.g. per-row enrichment fetches on a list page) — the interceptor
|
||||
* still throws so the caller's own catchError/error callback runs, it just skips the alert.
|
||||
*/
|
||||
export const SILENT_HTTP_ERROR = new HttpContextToken<boolean>(() => false);
|
||||
Reference in New Issue
Block a user