Dynamics Ax 2009,异常处理

Caf*_*eek 5 exception-handling x++ axapta dynamics-ax-2009

在我的x ++代码中,我有以下内容

void run() {
    try
    {
        startLengthyOperation();
        this.readFile();    
    }
    catch (Exception::Deadlock)
    {
        retry;
    }
    catch (Exception::Error)
    {
        error(strfmt("An error occured while trying to read the file %1", filename));
    }
    catch
    {
        error("An unkown error has occured");
    }

    endLengthyOperation();
}
Run Code Online (Sandbox Code Playgroud)

我正在进行最后一次捕获(之前,我没有得到关于异常的消息).但我想知道什么是真正发生并导致异常.我怎样才能找出异常是什么?

Mic*_*own 5

您可以将stackTrace添加到信息日志中,并在到达最后一个catch时添加一条信息消息.这将显示代码在达到捕获时的确切行为.