我对类型记录和角度2只是个新手,我想知道哪种方法最适合记录客户端错误,这样如果在生产中发生了问题,我就能够找出那个失败的方法是什么,以及抛出了什么错误。
应用程序的后端是用C#编写的,并连接到Server。数据是通过WebAPI调用检索的。
当前,任何服务器端错误都会记录到DB中。我正在考虑编写一个类型记录errorLoggingService,它将调用一个ErrorLoggingController API,然后将错误记录到DB中?
这看起来是一种合理的方法,还是有更好的方法来做到这一点?
下面是我现有的一个示例类型记录方法:
public getCustomerData(customerId: number, year: number) {
let apiUrl = this.myApiMethod;
let urlConcat = apiUrl + '/' + customerId + '/' + year + '/';
return this.http.get(urlConcat)
.map((response: Response) => <boolean> response.json())
.catch(this.handleError);
}
public handleError(error: Response) {
console.log(Error Handler Method Hit);
//this is where I would call to the Error logging service
// which would make an API call to log the error to db
//this.errorLoggingService.logClientError("Build Error Message");
return Observable.throw(error.json() || 'Server Error');
} 发布于 2018-07-23 10:44:44
最后我使用了jsnlog - http://jsnlog.com/。
Usersnap看起来也是一个有用的工具-- https://usersnap.com/e1/classic-008
https://stackoverflow.com/questions/43530156
复制相似问题