简体   繁体   English

如何捕获导致异常的值

[英]How to catch value that caused exception

Is there any way to catch the value of what caused an exception to be thrown?有什么方法可以捕获导致抛出异常的值? I'm currently using a Nest global exception filter that catches just about everything (a very basic one, identical to the one on Nest's documentation) and to show custom messages, I'm doing something like:我目前正在使用一个 Nest 全局异常过滤器,它几乎可以捕获所有内容(一个非常基本的异常过滤器,与 Nest 文档中的那个相同)并显示自定义消息,我正在执行以下操作:


catch(exception, host) {
if(exception instanceof AnyErrorObjectHere) {
 // log a custom message
}
}

What if I want to know what caused that issue?如果我想知道是什么导致了这个问题怎么办? If I tried to send an invalid value to my ORM or if I tried to parse something not parsable... Do my exception holds that value?如果我试图向我的 ORM 发送无效值,或者如果我试图解析不可解析的东西......我的异常是否保持该值?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM