Fun with exceptions: 2 lines make the simulator crash :S (can this please be fixed?)

Former Member
Former Member
I have a simple exception class.

class MyException
{
function initialize() {}
}


If I throw this in the compute function of a data field, I get an error. Just as expected.

The next few lines of code however make the simulator crash:

class MyException
{
function initialize() {}
}


function compute(info)
{
test();
}

function test()
{
throw new MyException();
}


This is a simple example, but when you add some classes, functions and other stuff, this error makes things very confusing :S
Took me a couple of days to find out that this was what was happening.
  • Bump. I'd like to be sure that this has been recognized as a bug.
  • Consider it recognized :) This is on my list. My guess is exceptions are broken with data fields when they are not caught, but they should work as long as you don't let them escape your app. If you catch it in the compute function it shouldn't crash.
  • Former Member
    Former Member over 10 years ago
    My guess is exceptions are broken with data fields when they are not caught.


    I wish it were that simple. There's a little more going on here. I get a lot of unexplainable problems when I use exceptions. The problem is I'm not able to reproduce them with simple examples that I can post on the forum.
    - If you throw an exception direct in the compute function, the app crashes, but the simulator doesn't;
    - I've had instances where a null reference exception inside a try block (where there's no catch for that error, of course) made the simulator crash
    - I've had instances where I had a function in my SimpleDataField class that was not used. When it was there everything was fine. When I removed it, everything else broke.

    The pattern I was implementing was a simple assertion class to make sure some criteria where met in the input:

    class Validator
    {
    //Use of single exception instance because of disposal bug
    var exception = new ValidationException();

    function isNotNull(value)
    {
    if (value == null)
    {
    throw exception;
    }
    }

    function greaterThan(value, testValue)
    {
    if (testValue >= value)
    {
    throw exception;
    }
    }

    function smallerThan(value, testValue)
    {
    if (testValue <= value)
    {
    throw exception;
    }
    }

    function isActiveActivity(info)
    {
    isNotNull(info.startTime);
    }
    }

    class ValidationException
    {
    function initialize() {}
    }