标签: uncaught-exception

Android全局错误处理和报告活动

我有没有办法注册一个全局错误处理程序,以防止应用程序崩溃?此处描述了崩溃报告:如何从Android应用程序获取崩溃数据?.我有一个想法是扩展这些解决方案以接受应用程序上下文,以便可以重定向到特定的报告活动?但是一旦报告崩溃,不确定应用程序上下文是否在此时有效?

但是,当发生崩溃时,如何将用户重定向到全局错误消息Activity?是否有一些高级方法来注册错误处理程序,以捕获所有错误并防止崩溃?有没有办法注册这样的处理程序,以便它可以防止或幸免于崩溃,然后将用户重定向到一个特定的活动,这将显示有问题的错误消息?

这是我对错误处理程序的修改:

1)只需将applicationContext构造函数作为ctx 传递给构造函数

2)添加reportError(stackTrace)方法将控制转移到错误消息页面

private void reportError(String stackTrace){
        Intent i = new Intent(ctx, DisplayErrorActivity.class);
        i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        i.setAction("DISPLAY_ERROR_ACTIVITY");
        Bundle b = new Bundle();
        b.putString("STACKTRACE", stackTrace);

        i.putExtras(b); 
        try{
             Log.d("MyErrorHandler","reportError ctx="+ctx);
             ctx.startActivity(i); 
        } catch (Exception e) {
             Exception ex = e;
             e.printStackTrace();
        }

    }
Run Code Online (Sandbox Code Playgroud)

reportError在下面打电话:

public void uncaughtException(Thread t, Throwable e) {
        Log.d("MyUncoughtExceptionHandler", "uncoughtException ctx="+ctx);
        String timestamp=getDateTime();
        final Writer result = new StringWriter();
        final PrintWriter printWriter = new PrintWriter(result);
        e.printStackTrace(printWriter);
        String stacktrace = result.toString(); …
Run Code Online (Sandbox Code Playgroud)

error-handling android crash-reports uncaught-exception

4
推荐指数
1
解决办法
9561
查看次数

Java [未选中]未经检查的案例警告

好吧,我一直在环顾四周,做了很多谷歌搜索,但我仍然找不到避免这种警告的方法.

Integer result = chooser.showOpenDialog(null);
if (result.equals(0))
{
    String tempHolder = chooser.getSelectedFile().getPath();
    filenameLoad = new File(tempHolder);
    filenameSave = filenameLoad;
    FileInputStream fis = null;
    ObjectInputStream in = null;
    try
    {
        fis = new FileInputStream(filenameLoad);
        in = new ObjectInputStream(fis);;
    }
    catch(IOException ex)
    {
        ex.printStackTrace();
    }

    try
    {
        loadFile = (ArrayList<Dot>)in.readObject();
    }
    catch(IOException ex)
    {
        System.out.println("Cast fail");
    }
    catch(ClassNotFoundException ex)
    {
        System.out.println("Cast fail");
    }
    catch (ClassCastException ex)
    {
        System.out.println("Cast fail");
    }

    try
    {
        in.close();
    }
    catch(Exception ex)
    {
        System.out.println("failed to close in");
    } …
Run Code Online (Sandbox Code Playgroud)

java uncaught-exception

3
推荐指数
1
解决办法
1843
查看次数

NSArrayM insertObject:atIndex:]:object不能为nil'

经过大量的搜索,并尝试使用stackoverflow上的一些解决方案,我没有找到任何可以解决我的错误的答案:我有一个UIViewcontroller,谁的名字是WorldViewController.在这个UIViewcontroller中,我初始化了一些UIViews.我想从一些UIViews修改一些依赖于WorldViewController的变量.现在,我把这些线条:

WorldViewController * World = [[WorldViewController alloc] init];
Run Code Online (Sandbox Code Playgroud)

它给了我:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
Run Code Online (Sandbox Code Playgroud)

那么,如何解决呢?它可能来自WorldViewController正在运行的事实吗?那么,如何修复呢?

编辑:我的viewcontroller的init方法

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization

        World1 = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 480.0)];
        [World1 setBackgroundColor:[UIColor blackColor]];
        [self.view addSubview:World1];
        [World1 release];

        [self.view addSubview:ViewPig];
        [self.view addSubview:level1view];
        [self.view addSubview:level2view];
        [self.view addSubview:LoadView];
        [LoadView AnimPigLoadingWith:PigChargement];
        [LoadView AppearLabelLoading];
        [self.view addSubview:FondPauseGrise];
        [self.view addSubview:FondPause];
        [self.view addSubview:BoutonResume];
        [self.view addSubview:BoutonHome];
        [self performSelector:@selector(Chargement) …
Run Code Online (Sandbox Code Playgroud)

objective-c uiviewcontroller uiview uncaught-exception ios

3
推荐指数
2
解决办法
2万
查看次数

Typescript和Uncaught SyntaxError:在严格模式之外尚不支持块范围的声明(let,const,function,class)

我有一个包含类定义的打字稿文件:

if (window.console == null) {
    (<any>window).console = {
            error: function (a) {
        },
            log: function (a) {
        }
    };
}

class SendMessage {
    //.....
}
Run Code Online (Sandbox Code Playgroud)

在编译为javascript(通过VS2015)之后,我在类定义的行上得到了错误:

Uncaught SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
Run Code Online (Sandbox Code Playgroud)

我发现我必须使用严格模式.但为什么以及如何在打字稿中使用它呢?

谢谢

javascript uncaught-exception typescript visual-studio-2015

3
推荐指数
1
解决办法
2万
查看次数

开启cypress uncaught:关闭后异常

我目前正在尝试第一次使用 Cypress,并在某个测试期间关闭 cypress uncaught:Exception,但我想在测试完成后将其打开。我怎样才能做到这一点 ?谢谢

PS:我这样禁用它`

cy.on('uncaught:exception', () => false);
Run Code Online (Sandbox Code Playgroud)

javascript uncaught-exception cypress cypress-cucumber-preprocessor

3
推荐指数
1
解决办法
237
查看次数

php:在catch()中重复函数调用2-3次

所以一个函数有时崩溃(未被捕获的异常),我想重新调用它2次,当发生延迟1秒时,让我们说.这是代码,但它似乎不起作用:

$crashesn = 0;

function checkNum($number) {
    echo $number . "<br>";
    if ($number>1) {
        throw new Exception("Value must be 1 or below");
    }
    return true;
}

try {
    checkNum(2);
    echo 'If you see this, the number is 1 or below';
}

catch(Exception $e) {
    $crashesn++;
    echo "crashes number:".$crashesn."<br>";
    if ($crashesn <= 2) {
        sleep(1);
        checkNum(2);
    } else {
        echo "MESSAGE: " .$e->getMessage();
    }
}
Run Code Online (Sandbox Code Playgroud)

checknum是抛出异常的函数(这里每次抛出异常都会崩溃).问题是,当我运行这段代码时,我仍然在我的页面上出现错误消息

Fatal error: Uncaught exception 'Exception' with message 'Value must be 1 or below' in G:\fix\ta_dll\test.php:30 …
Run Code Online (Sandbox Code Playgroud)

php repeat uncaught-exception

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

捕获node.js中未捕获异常的源或行号

我有一个在 IIS 中运行的 Node.js Express 应用程序。我发现该应用程序经常由于一些未捕获的异常而崩溃。因此,我使用 process.on('uncaughtException') 来重新启动服务,以防出现未捕获的异常。我能够得到“ECONNRESET”错误,但我无法了解实际发生的情况。有没有办法捕获导致异常的错误源或行号?

node.js uncaught-exception express

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

GWT Uncaught异常逃脱

我使用GWT创建了一个新的谷歌应用程序,它运行正常.但是,当我单击一个负责与服务器端执行某些操作的按钮时,它会抛出异常错误.请有人可以提供帮助吗?提前谢谢:(这是代码:

package com.ukstudentfeedback.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.ukstudentfeedback.shared.FieldVerifier;
import com.ukstudentfeedback.client.MailClient;
import com.ukstudentfeedback.client.MailClientAsync;

public class Ukstudentfeedback implements EntryPoint{

    private static final String SERVER_ERROR = "An error occurred while "
            + "attempting to contact the server. Please check your network "
            + "connection and try again.";

    /**
     * Create a remote service proxy to talk to the server-side Greeting service.
     */ …
Run Code Online (Sandbox Code Playgroud)

gwt uncaught-exception

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

在node.js中,如何在处理uncaughtException中的异常时重新启动服务器

在我的应用程序中我使用uncaughtException来处理应用程序错误.在这个如何重新启动服务器.

node.js uncaught-exception

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

发生快速错误时,pm2 不会重新启动工作程序

我正在使用 pm2 来管理我的 nodejs express 应用程序(以集群模式运行)中的进程。

我们有两种错误处理程序

实际上,我没有声明这样的处理程序,因为在这种情况下让 pm2 检测到死亡的工人,因此会自动重新启动死亡的工人。

  • 第二:express error handler,我的意思是错误将被转发到express error handler,而不是uncaughtException handler,错误处理程序如下

    app.use(function(err, req, res, next) {})
    
    Run Code Online (Sandbox Code Playgroud)

我也没有为了与 uncaughtException 相同的目的声明这个错误处理程序。但是在这种情况下 pm2 不会重新启动节点。

对这个问题有什么想法吗?非常感谢

error-handling node.js uncaught-exception express pm2

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

Cypress 无法 cy.visit() 因为页面抛出未捕获的异常

这个错误已经让我几个月无法使用 cypress

/// <reference types="cypress" />

describe('User login', () => {
  beforeEach(() => {
    cy.visit('http://localhost:8080')
  })
  // ...
})
Run Code Online (Sandbox Code Playgroud)

我收到一条错误消息:

(uncaught exception)TypeError: Failed to set an indexed property on 'DOMStringList': Indexed property setter is not supported.
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述


更多细节:

应用程序规格:

  • 反应16.14.0
  • 反应路由器-dom 4.3.1
  • 反应-redux ^5.0.4"

看来错误是由于某些加载造成的(假设是 webpack) GET 200 /sockjs-node/info?t=1672024046431

我注意到如果我注释掉应用程序的其余部分似乎加载的特定组件(标题栏)

javascript uncaught-exception reactjs cypress

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

加载谷歌地图,一个奇怪的错误:未捕获的语法错误:意外的标记?在旧版本的 Chrome 中

当我尝试加载谷歌地图时,我在一些旧版本的 chrome(可能是 2019 年)中遇到了奇怪的错误(我使用的是嵌入式 chrome 浏览器)。它不会在当前版本的 chrome 中抛出错误。(2020 年及以后版本没问题)它突然开始了。

<script src="https://maps.googleapis.com/maps/api/js?key=apikey"></script>
Run Code Online (Sandbox Code Playgroud)

js?key=apikey:67 未捕获的语法错误:意外的标记?

我真的很好奇可能是什么错误,有人能解释一下吗?

谢谢

javascript uncaught-exception

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

如何查找和修复未捕获的异常?

我不知道如何弄清楚未捕获的异常来自何处.我查看了stackoverflow帖子,并尝试寻找几个解决方案.据我所知,我的活动,"监视器",列在我的清单中,它是包的一部分.但是当我启动"Monitor"活动时,我得到一个空指针异常.我应该寻找什么才能找到这个例外?

02-03 21:44:14.192: E/Trace(19701): error opening trace file: No such file or directory (2)
02-03 21:44:14.262: I/BugSenseHandler(19701): Registering default exceptions handler
02-03 21:44:14.633: I/Setup(19701): Setup activity created
02-03 21:44:14.813: I/BugSenseHandler(19701): Flushing...
02-03 21:44:14.823: I/BugSenseHandler(19701): Registering default exceptions handler
02-03 21:44:15.023: W/BugSenseHandler(19701): Transmitting ping Exception No peer certificate
02-03 21:44:15.403: I/Adreno200-EGLSUB(19701): <ConfigWindowMatch:2087>: Format RGBA_8888.
02-03 21:44:15.594: E/(19701): <s3dReadConfigFile:75>: Can't open file for reading
02-03 21:44:15.594: E/(19701): <s3dReadConfigFile:75>: Can't open file for reading
02-03 21:44:19.318: W/dalvikvm(19701): threadid=1: thread exiting with uncaught exception …
Run Code Online (Sandbox Code Playgroud)

android uncaught-exception

0
推荐指数
1
解决办法
562
查看次数