Highlighted

displaying runtime errors in android/ios installed app

Contributor ,
Sep 20, 2017

Copy link to clipboard

Copied

I've been trying to get errors to display in a text field within the app for ease of error reporting from users.

I've had some success using this at the top level of the app but it's not working on device:

//start code

this.loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, errorHandler);

function globalErrorHandler(event:UncaughtErrorEvent):void

{

    var message:String;

    //check for runtime error

    if (event.error is Error)

        message = (event.error as Error).getStackTrace();

    //handle other errors

    else if (event.error is ErrorEvent)

        message = (event.error as ErrorEvent).text;

    else

        message = event.error.toString();

    //do something with message (eg display it in textfield)

    myTextfield.text = message;

}

//end code

At first this wouldn't work on the device and I thought it was because upon the error, when developing on the pc, flashplayer would display the actionscript popup with the error. Which you would need to click "dismiss all" or close and then the globalErrorHandler was called after and then the error written to the textfield. I thought this is what was keeping it from showing up on the device. However, by adding event.preventDefault() I was able to suppress the actionscript popup when developing on the desktop and the error was written to the textfield successfully. This was not the case however on the andriod device. It still just hangs on the error. It's as if the default error event cannot be suppressed on android.

Any help very much appreciated!

TOPICS
Development

Views

228

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

displaying runtime errors in android/ios installed app

Contributor ,
Sep 20, 2017

Copy link to clipboard

Copied

I've been trying to get errors to display in a text field within the app for ease of error reporting from users.

I've had some success using this at the top level of the app but it's not working on device:

//start code

this.loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, errorHandler);

function globalErrorHandler(event:UncaughtErrorEvent):void

{

    var message:String;

    //check for runtime error

    if (event.error is Error)

        message = (event.error as Error).getStackTrace();

    //handle other errors

    else if (event.error is ErrorEvent)

        message = (event.error as ErrorEvent).text;

    else

        message = event.error.toString();

    //do something with message (eg display it in textfield)

    myTextfield.text = message;

}

//end code

At first this wouldn't work on the device and I thought it was because upon the error, when developing on the pc, flashplayer would display the actionscript popup with the error. Which you would need to click "dismiss all" or close and then the globalErrorHandler was called after and then the error written to the textfield. I thought this is what was keeping it from showing up on the device. However, by adding event.preventDefault() I was able to suppress the actionscript popup when developing on the desktop and the error was written to the textfield successfully. This was not the case however on the andriod device. It still just hangs on the error. It's as if the default error event cannot be suppressed on android.

Any help very much appreciated!

TOPICS
Development

Views

229

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Sep 20, 2017 0

Have something to add?

Join the conversation