Вопрос

I'm working on some flash app. Now, to test customer side of it I can use Flash Player debugger version that will save logs and show error messages. When it's deployed on the customer side - they will have a regular Flash Player version which means I will have no access to error messages if errors will happen. So I would like to equip it with some tool that would capture all of my trace messages in code and errors text. As for trace messages that's fairly simple, I just override the function in my code so it sends a POST request with trace message to a logger server, but how can I get a hold of the error message? Is there a known approach to this or some trick that somebody can suggest?

Это было полезно?

Решение 2

I've discovered this post on StackOverflow: How to catch all exceptions in Flex?

It answers my question, strange that I haven't ran into it while I was googling prior to asking.

Другие советы

You can install the debug version of flash as your browser's default (in Chrome, you must disable the built-in player), so if you wanted to test user experience and debug, this would be the ideal solution.

However, to answer your question: there's no method for universally catching all errors, and redirecting them (that I know of). You'd have to encapsulate problem code ahead of time with try...catch statements, and send the property back on catch. For example:

try {
    this["foo"]();
} catch (e:Error) {
    trace(e);
}

In the debug version, the traced value would be TypeError: Error #1006: value is not a function. And while the standard version will only output TypeError: Error #1006, (a notably less descriptive error), what we're missing is any reference to where the error occured. To get this, we need to use Error.getStackTrace() to see the call stack and the line where the error occurred. In debug, this outputs the following:

TypeError: Error #1006: value is not a function.
    at Shell_fla::MainTimeline/init()[C:\Projects\shell.as:91

In the standard client, we get a dissapointing null. In short, you cannot get any valuable info from the client versions.

The best advice I can give is to write around your problem code with your own custom error reports. For example, catch IO errors and trace the file it failed to load, or if you're expecting an object.foo, first try if (object.hasOwnProperty("foo")) { // do something } else { trace("foo not found in " + object.name) }. Code defensively.

Cheers,

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top