我正在使用Angular和TypeScript.在API调用的情况下,我使用了try catch构造来进行错误处理.如果在try块中发生任何错误,它就不会捕获阻塞.应用只在那里终止.
我也尝试过使用throw过.这是一个示例代码段,
try {
this.api.getAPI(Id).subscribe( // this.api is my api service and getAPI is present there
(data: any) => {
if (data == null) {
throw 'Empty response';
}
},
(error: HttpErrorResponse) => {
console.log(error);
};
} catch(e) {
console.log(e);
}
Run Code Online (Sandbox Code Playgroud)
在某些情况下,来自API的"数据"返回'null',但throw不会捕获块ALSO,尝试不抛出,它为'data'提供null错误...在这种情况下也不会捕获块.
我在C#项目的asp.net中使用HMTL文本编辑器。因此,如何将编辑器内容存储在SQl Server 2008 DB中,以便在网页上进行编辑时将其提取出来,这意味着在将数据提取到网页上时必须显示相同的编辑效果。
请帮忙
在此先感谢Nils