Question

In my x++ code I have the following

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();
}

I am hitting the final catch (prior, I was getting no message about exceptions). But I want to know what is REALLY happening and causing the exception. How can I find out what the exception is?

Was it helpful?

Solution

You could add stackTrace to the info log and add an info message when you get to the last catch. That would show you exactly what the code was doing at the time it reached the catch.

OTHER TIPS

A couple of things: - Deadlock as far as I know catches deadlocks in database requests. Not sure what readFile is doing but it doesn't sound like its querying the database. - The methods startLengthyOperation (and end) are there to make the mouse cursor look like the hourglass duing the lengty operation.

Not sure what the readFile does. When I think of AsciiIO and TextIO they normally read into something, so I can only assume you're doing that within readFile. I tend to do these checks: Check if filepath is something other than empty. Use FileIOPermission to assert read or write. Create the instance of the AsciiIO or TextIO object with the filepath as input. Check if the object is valid, and if not alert the user.

Hope this helps, and if so, please vote.

It could easily be Exception::CLRError, in which case to see the problem you could choose to re-throw the error:

throw error(AifUtil::getClrErrorMessage());

or Exception::Internal, then something like:

System.Exception e = CLRInterop::getLastException();
if (e)
    throw error(e.ToString());

or Exception::CodeAccessSecurity or anything else - you'd need to show the code from this.readFile() first. When you're debugging your code what line is causing the error?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top