如何处理 javascript Web 应用程序中由用户引起的错误?
例如,在PHP或其他服务器端程序中,我可以将用户引起的所有错误保存到服务器。
我可以知道是否发生错误并可以修复它们。
但在使用 javascript 的 Web 应用程序中,我不知道用户会导致什么错误。
我无法修复它们。
如何将 JavaScript Web 应用程序的错误保存到服务器以了解并修复它们?
将 javascript 错误保存到服务器是一种常见且有效的方法吗?
或者有更好的方法来处理这个问题吗?
许多“javascript Web 应用程序开发人员”如何了解并修复其发布的 javascript Web 应用程序中的错误?
或者我不应该担心用户造成的错误吗?
For example, in PHP or other server side programs, I can save all errors which caused by users to the server.
And I can know if errors occurred or not and can fix them.
But in web applications using javascript, I don't know what errors are caused by users.
And I can not fix them.
How to save errors of javascript web applications to the server to know and fix them?
And saving javascript errors to the server is a common and effective approach?
Or are there better approaches to deal with the problem?
How do many "javascript web application developers" know and fix the errors of their published javascript web applications?
Or shouldn't I worry about the errors caused by users?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Javascript 还具有
try/catch
块,可用于捕获错误并提交到服务器。并非每个错误都值得保存到服务器。根据错误的严重性,您需要决定保存/记录哪些错误以及以不同方式处理哪些错误。
例如,数字验证可以通过
alert()
或突出显示错误spans/divs
向用户显示;而如果密码验证失败n
次,您可能需要记录传入的 IP 地址和其他数据,以便您审核系统是否存在潜在违规行为。Javascript also has
try/catch
blocks that you can use to trap errors and submit to server.Not every error is worth saving to server. Based on the severity of error, you need to decide which ones to save/log and which ones to handle differently.
E.g., number validation is something that you can display to user via
alert()
or highlighted errorspans/divs
; whereas if password validation fails forn
number of times, you might want to log the incoming IP address and other data that lets you audit your system for potential breaches.