标签: uncaughtexceptionhandler

Spring中的Thread.setDefaultUncaughtExceptionHandler

我正在开发一个Spring应用程序,并且想知道是否有一部分框架允许我以更优雅的方式执行此类操作,例如在XML中配置某些内容?

java spring uncaughtexceptionhandler

7
推荐指数
1
解决办法
3672
查看次数

Android重启应用程序

我试图在android使用时发生崩溃时重新启动应用程序Thread.UncaughtExceptionHandler.我可以使用当前活动堆栈作为新进程重新启动应用程序吗?如果是的话我该怎么办?

android restart uncaughtexceptionhandler

7
推荐指数
1
解决办法
426
查看次数

处理来自引用dll的未处理异常

我创建了ac#dll来处理应用程序中所有未处理的异常.

添加

AppDomain appDomain = AppDomain.CurrentDomain;
appDomain.UnhandledException += new UnhandledExceptionEventHandler(MyErrorHandler);
Run Code Online (Sandbox Code Playgroud)

我的dll项目中的代码,添加了对我的应用程序的引用.

在调试时,如果我的应用程序抛出一个未经处理的异常,它会自动从dll中捕获并成功登录到文件.

但是当我的应用程序被部署(或直接执行我的应用程序(双击exe))时,dll无法从应用程序捕获未处理的异常.

.net c# dll exception uncaughtexceptionhandler

7
推荐指数
1
解决办法
3294
查看次数

Android UncaughtExceptionHandler 完成应用程序

我想在记录未处理的异常后关闭应用程序。在这里搜索后我做了以下事情:

public class MyApplication extends Application {
    //uncaught exceptions
    private Thread.UncaughtExceptionHandler defaultUEH;

    // handler listener
    private Thread.UncaughtExceptionHandler _unCaughtExceptionHandler = new Thread.UncaughtExceptionHandler() {
        @Override
        public void uncaughtException(Thread thread, Throwable ex) {
            ActivityManager am = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
            //logging code
            //..........

            //call the default exception handler
            defaultUEH.uncaughtException(thread, ex);

        }
    };

    public MyApplication() {
        defaultUEH = Thread.getDefaultUncaughtExceptionHandler();
        Thread.setDefaultUncaughtExceptionHandler(_unCaughtExceptionHandler);
    }
}
Run Code Online (Sandbox Code Playgroud)

打电话后,defaultUEH.uncaughtException(thread, ex);我尝试打电话System.exit()android.os.Process.killProcess(android.os.Process.myPid());甚至我发现一些帖子被告知要同时使用)。问题是我遇到黑屏,我必须使用手机任务管理器强制应用程序退出。我究竟做错了什么?

问候

android uncaughtexceptionhandler

7
推荐指数
1
解决办法
5794
查看次数

UncaughtExceptionHandler没有捕获异常

我不确定为什么没有调用uncaughtException方法.

static
{
    /**
     * Register a logger for unhandled exceptions.
     */
    Thread.UncaughtExceptionHandler globalExceptionHandler = new Thread.UncaughtExceptionHandler()
    {
        @Override
        public void uncaughtException(Thread t, Throwable e)
        {
            System.out.println("handle exception."); // can also set bp here that is not hit.
        }
    };

    Thread.setDefaultUncaughtExceptionHandler(globalExceptionHandler);
    Thread.currentThread().setUncaughtExceptionHandler(globalExceptionHandler);

    /**
     * Register gateway listen port.
     */
    try
    {
       // some stuff that raises an IOException
    }
    catch (IOException e)
    {
        System.out.println("Throwing exception");
        throw new RuntimeException(e);
    }

}
Run Code Online (Sandbox Code Playgroud)

程序输出是:

投掷例外

java.lang.ExceptionInInitializerError
Caused by: java.lang.RuntimeException: java.io.FileNotFoundException: blah.jks 
    (The system …
Run Code Online (Sandbox Code Playgroud)

java uncaughtexceptionhandler

5
推荐指数
1
解决办法
1236
查看次数

如何将未捕获的异常处理程序/完成附加到 CompletableFuture 链

用例

结果:异常永远不会被捕获,并且没有跟踪/记录它。在异步系统的情况下,这是 1) 不可取的和 2) 要发现的硬和隐藏问题(例如 NPE、Runtime Exc 等)的指标。

问题:与java.lang类比/以类似方式实现CompletableFuture.UncaughtExceptionHandler机制是否可行。Thread.UncaughtExceptionHandler?如果 CompletableFuture 链没有附加 java.util.concurrent.CompletableFuture.UniExceptionally Completion,则提供 [默认] 未捕获的异常处理程序/完成。

java-8 uncaughtexceptionhandler completable-future

5
推荐指数
1
解决办法
323
查看次数

javascript try catch 语句在我的代码中不起作用

  1. 我收到“未捕获的语法错误:无效或意外的标记”错误。
  2. 并尝试使用“try ~ catch”进行捕获,但它不起作用。

    function a(){
      try{
       var img1 = "=="";  <#-- it occurs error -->
      }catch (e) {
        console.log("image error:" + e.message);
      }
    }
    
    Run Code Online (Sandbox Code Playgroud)

javascript error-handling try-catch uncaughtexceptionhandler

-2
推荐指数
1
解决办法
6402
查看次数