开发者

Flex: Meanful errors? is there a way to show them as a human readable?

开发者 https://www.devze.com 2023-03-18 20:07 出处:网络
Is there a way to show the handled errors as human readable, without need to search the interent about the error code ?
  • Is there a way to show the handled errors as human readable, without need to search the interent about the error code ?

For instance :

try
{
   ... a block which could fail
}
catch( e : Error )
{
   Alert.show( e.message );
}

anyway - there is n开发者_如何学编程ot actuall description of the error, just the error code.


Assuming you mean a runtime error within flex, you can decompose the error object and there are a number of descriptors.

The base error class Error (a top level object) can be found here : http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/Error.html

Regardless of the specific error type (so an IOError for example), they will have these basic elements of the Error class. That said, you can always dump the .message property:

mx.controls.Alert.show('Error:\n ' + myErrorObj.message );

My suggestion for you would be to use debug mode and take a look at the error object when it is thrown.

You can get more detailed if you catch specific types of errors. For example, in a service fault event, you can do something like :

mx.controls.Alert.show('Oops:\n ' + faultEvent.fault.faultString );

This would display "HTTP request error" rather than the code "Error #2032"

0

精彩评论

暂无评论...
验证码 换一张
取 消