I m trying to implement a global error notification but I m not managing to inject anything into the Interceptor and the worst thing is that it doesn t give an error, it just doesn t work, if anyone can shed some light, I d appreciate it, below project specifications -Angular v16 -Full standalone -PrimeNG
main.ts
bootstrapApplication(AppComponent, {
providers: [
provideRouter(routes),
provideAnimations(),
provideHttpClient(withInterceptors([ErrorHandlerInterceptor])),
importProvidersFrom(MessageService, ToastModule),
],
}).catch((err) => console.error(err));
error-handler.interceptor.ts
export const ErrorHandlerInterceptor: HttpInterceptorFn = (req, next) => {
console.log( here comes );
const messageService: MessageService = inject(MessageService);
console.log( Not here );
messageService.add({
severity: success ,
summary: Success ,
detail: Message Content ,
});
return next(req).pipe(
catchError((error) => {
if (error.status === 0) {
}
if (error.status === 500) {
}
console.log( cath );
return throwError(() => new Error(error));
})
);
};
I tried to create a service with the MessageService inside and even then it didn t help and it doesn t return any error, the HTTP call simply goes to limbo.