Toast interceptor
An HttpInterceptorFn that turns a failed HttpClient request into a toast for the status codes worth telling the user about, without wrapping HttpClient itself.
toastInterceptorFn watches the Angular HttpClient channel and raises a toast (through @sinequa/atomic's
notification system) for the handful of error statuses a user should actually hear about — leaving every other
failure to whatever already handles it.
Two interceptors, disjoint requests
provideAtomicNotifications() does the same job for the Sinequa
client's own requests, by listening to its requestFailed event — a different channel entirely. The two
cover disjoint request sets (the client's, versus HttpClient requests from @sinequa/agent,
@sinequa/assistant or your own code), so registering both raises exactly one toast per failure, never two.
Minimal example
import { ApplicationConfig } from "@angular/core";
import { provideHttpClient, withInterceptors } from "@angular/common/http";
import { toastInterceptorFn } from "@sinequa/atomic-angular";
export const appConfig: ApplicationConfig = {
providers: [provideHttpClient(withInterceptors([toastInterceptorFn]))],
};How it works
Requests to api/v1/audit.notify pass through untouched — auditing itself must never trigger a notification
about a failed audit call. Every other request is watched for:
401during an active user-override, with a specific server error code — shown once as "Cannot override user: Unauthorized access", then a request-scoped flag suppresses a repeat toast for the same request context.400,403,500,503— shown as${statusText}: ${errorCodeText} — ${errorMessage}, with two exceptions: a400fromapi/v2/user-profile(handled by the caller instead) and any status fromapi/v1/preview(preview failures are shown in the preview surface itself, not as a toast).