问题标签 [angular-errorhandler]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
angular - Angular, Http Error 阻止任何进一步的请求
在服务器做出错误响应后,我的应用程序不会发送任何进一步的请求。
我正在发送一个请求:
我的错误处理程序:
我的管道如下所示:
我可以在控制台中看到“错误捕获”消息,updateRules()
即使在错误情况下,该方法似乎也能正常工作。
但是,在 404-Error-Response 之后,ngAfterViewInit()
不再调用该方法。UI 钢对交互做出反应。
angular - Is it possible to ignore some errors conditionally, in global error handler of Anguler
I have situation where I call an API to save data both manually and automatically,
- In case of manual save I want to show the error if save fails, and I achieved this using angular global error handler.
- In case of automatic save I want to ignore the error, but as I have global error handler its catching the error and showing it to user as per the implementation.
I am trying to find a way to manage this error handling based on some condition.
following are some code snippets for better understating of problem
Global error handler
Save method
what I want is global error handler should ignore errors in this call if "skipSpinner" is 'true'
angular - 自定义 ErrorHandler 提供程序为响应异步事件而打开的对话框未关闭
我有一个通用的警报对话框组件,我在整个 Angular 应用程序(简化)中用于各种目的......
对话框窗口在 app.module 提供程序中指定默认选项:
我还实现了一个自定义 ErrorHandler 提供程序,它通过警报对话框显示相关错误。
显示的错误经常是后端服务器异步返回的错误。
在异步抛出错误的情况下,对话框不会关闭以响应按钮(即使使用(click)="closeDialog()"
处理程序),除非您单击按钮然后还单击按钮外的其他位置。
我有一个 StackBlitz 项目,在这里演示了这个问题: https ://stackblitz.com/edit/angular-ivy-b3fqjj
有没有办法通过单击一个按钮来关闭异步打开的对话框?
angular - Angular、ErrorHandler 和 BehaviorSubject:仅第二次单击更新消息
我正在尝试实现一个通用的 http 处理程序错误,但我发现了一个错误的行为。我的错误组件仅在第二次单击后才更新消息错误,但我不知道为什么。
代码在 StackBlitz 中可用:在此处输入链接描述
在 app.component.ts 点击我尝试一个 http 请求,它会失败,只是为了抛出一个错误。
所有错误都在 global.error.ts 中处理,每个错误都添加到 error.service.ts 中:
error.service.ts 使用 BehaviorSubject 并通知我的 error.component.ts:
最后,error.component.ts 必须在屏幕上更新消息错误,但它只在第二次单击时有效,但 console.log 完美运行。
问题:
- 这种行为有什么原因吗?
- 对实现全局处理程序 Http 错误有什么建议吗?