首页 \ 问答 \ 如何识别具有特定数据的throwable(How to identify a throwable with specific data)

如何识别具有特定数据的throwable(How to identify a throwable with specific data)

我抓住了这个捕获任何未捕获的异常

Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
            @Override
            public void uncaughtException(Thread t, Throwable e) {
   }
});

在方法内部,我想以不同于其他异常的方式处理以下异常:

Caused by: java.lang.NullPointerException
    at com.company.si.stats.Statistics.hashString(Statistics.java:192)
    at com.company.si.stats.Statistics.sendStatistics(Statistics.java:127)

我想基本上检查它是来自com.company.si.stats.Statistics.hashString nullpointer异常

我怎样才能做到这一点? 我不确定我应该比较一下throwable中的哪些参数?

抛出异常的代码不是我写的,所以我无法改变它。

重要说明我知道我接近这个问题的方式不正确。 但我无法访问提高异常的库,我需要一个解决方法,直到在库中修复了错误。 选择答案是因为它满足了我的需要,而不是通常应该是什么


I have this caught that catches any uncaught exception

Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
            @Override
            public void uncaughtException(Thread t, Throwable e) {
   }
});

Inside the method, I want to deal with following exception differently than other exceptions:

Caused by: java.lang.NullPointerException
    at com.company.si.stats.Statistics.hashString(Statistics.java:192)
    at com.company.si.stats.Statistics.sendStatistics(Statistics.java:127)

I want basically to check that it is nullpointer exception coming from com.company.si.stats.Statistics.hashString

How can I do that? I am not sure what parameters in throwable I should compare against?

The code where exception is thrown was not written by me, so I cannot change anything about it.

Important NOTE I know the way I am approaching this problem is not the right way. But I dont have access to the library raising the exception and I needed a workaround till the bug is fixed in the library. The answer was chosen because it satisfies what I need to, and not what generally should be dne


原文:https://stackoverflow.com/questions/40445610
更新时间:2023-12-20 08:12

最满意答案

我记得在邮件列表上看过这个主题......

http://grails.1312388.n4.nabble.com/Incremental-Deployment-td3066617.html

...他们建议使用rsync或xdelta3仅传输更新的文件。 没试过,但它可能对你有所帮助?


I remember seeing this subject on the mailing list...

http://grails.1312388.n4.nabble.com/Incremental-Deployment-td3066617.html

...they recommend using rsync or xdelta3 to only transfer updated files. Haven't tried it, but it might help you?

相关问答

更多
  • 你不需要SVN下的./plugins/core(Core Grails插件) 在SVN下你不需要./web-app/WEB-INF/下的任何东西。 你通常不需要把文件放在这里。 如果需要提供任何内容,则./conf中的文件将复制到WEB-INF / classes中,以便它们位于类路径中。 以下是更详细描述的文档链接 。 You do not want ./plugins/core (Core Grails plugins) under SVN You do not want anything under ...
  • 我不建议在Raspberry Pi上运行任何非“Hello World”样式的Grails应用程序。 通常 ,512MB的RAM是最小的,以便在中小型应用程序上具有良好的性能。 Tomcat内存使用率+ 512MB RAM上的应用程序内存使用量对我来说在Raspberry Pi上看起来不太好...... 请参阅Igor 关于这个相关SO问题的第二个答案。 请考虑其他替代方案Spring MVC或更轻量级的东西(没有太多的代理,Web框架中的反射量少等)。 I would not recommend runn ...
  • 它现在正在工作,原始行compile "org.springframework.boot:spring-boot-starter-tomcat" 。 。 。 我只是改变了provided "org.springframework.boot:spring-boot-starter-tomcat" 愚蠢的我,当我应该替换原来的时候,我添加了新的依赖关系! 。 。 。 我喜欢贴纸 dependencies { . . . //compile "org.springframework.boot:sp ...
  • 我们通过CloudFoundry运行ShareYourLove.com,它运行良好。 它不会超过标准EC2费用。 最好的选择(如果你还没有收到CF登录)是购买像http://www.linode.com这样的低成本Linux机器,并自己安装tomcat和mysql。 干杯 背风处 We are running ShareYourLove.com via CloudFoundry and it works well. It doesn't cost us any extra over the standard ...
  • Grails尝试在您启动tomcat的目录中写入文件stacktrace.log。 “权限被拒绝”错误可能意味着tomcat缺少对该文件夹的写入权限。 也许你从tomcat进程无法访问的文件夹中启动tomcat? 尝试从例如其日志目录(运行../bin/startup.sh )启动tomcat,看看是否有效。 编辑:以上是错误#2。 基本原因看起来是用数据源初始化spring bean的问题。 用户'grails'@'localhost'无法访问localhost上的MySQL数据库 Grails trie ...
  • 原来这个问题与“熵源”有关,正如Tomcat wiki上关于如何加速启动Tomcat的记录。 因此解决方案是将以下JDK选项添加到Tomcat配置文件中:/ etc / default / tomcat7: -Djava.security.egd=file:/dev/./urandom 现在Tomcat可以在大约20-30秒内可靠地启动。 It turned out this problem was related to the "Entropy Source", as documented on the ...
  • 对此的解决方案与此答案几乎相同。 内置属性basedir和PluginBaseDir区分目标应用程序和插件目录。 The solution to this is almost the same as this answer. The built-in properties basedir and PluginBaseDir differentiate the target app and the plugin directories.
  • 我记得在邮件列表上看过这个主题...... http://grails.1312388.n4.nabble.com/Incremental-Deployment-td3066617.html ...他们建议使用rsync或xdelta3仅传输更新的文件。 没试过,但它可能对你有所帮助? I remember seeing this subject on the mailing list... http://grails.1312388.n4.nabble.com/Incremental-Deployment ...
  • 找到'解决方案',以防其他人在寻找。 如果我将插件的声明从application.properties移动到BuildConfig.groovy,则错误消失。 我不确定它是否真的“修复”它或者它是否导致清理/重新安装可能已经清除它的tomcat插件,但它删除了部署时的错误。 在此之后我遇到了另一个错误,JBoss hibernate libs比Grails 2.1.1依赖项中的更旧: Caused by: java.lang.NoSuchMethodException: org.hibernate.vali ...
  • 对于上面提到的警告:安装cloud-foundry插件后: 打开dependencies.groovy文件并更改compile(“:cloud-support:[1.0.7,)”)以编译':cloud-support:1.0.8'。 在plugin.xml version = [1.0.7,)“更改为version ='[1.0.8]'。 现在运行grails cf-info ..不会填充任何警告。 For the above mentioned warning: After installing the ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。