actionscript 3 - Why isn't my exception being caught? -
this stack trace get:
[fault] exception, information=error: directory id 3 in use @ cantrips.assets.index::assetindex/diridchanged()[/home/luismasuelli/proyectos/flash-assets-index-ritual/assets-index-loader/src/cantrips/assets/index/assetindex.as:72] @ flash.events::eventdispatcher/dispatcheventfunction() @ flash.events::eventdispatcher/dispatchevent() @ cantrips.assets.index::assetdirectory/set id()[/home/luismasuelli/proyectos/flash-assets-index-ritual/assets-index-loader/src/cantrips/assets/index/assetdirectory.as:68] @ main/updateselecteddirectory()[/home/luismasuelli/proyectos/flash-assets-index-ritual/assets-index-editor/src/main.mxml:192] @ main/__dirupdatecurrent_click()[/home/luismasuelli/proyectos/flash-assets-index-ritual/assets-index-editor/src/main.mxml:401]
this implementation of main/updateselecteddirectory():
private function updateselecteddirectory():void { try { var newid:uint = uint(dirid.text); var newname:string = stringutil.trim(dirname.text); var selecteddirectory:assetdirectory = assetbrowsertree.selecteditem assetdirectory; if (selecteddirectory) { selecteddirectory.id = newid; selecteddirectory.name = newname; assetbrowsertree.expanditem(selecteddirectory.parent, false); assetbrowsertree.expanditem(selecteddirectory.parent, true); } } catch (error:error) { alert.show(error.message, "cannot update"); } }
why not exception being caught try {} catch(error:error) {}
?.
the exception exception created me, well-understood scenario triggered (i created exception , designed scenarios , testing them; exception triggered expect). tried using exact name of exception (assetindexerror) in catch block, , no confusion or ambiguous name exists (this means: there's no assetindexerror class declared elsewhere importing instead of this).
explanation:
- cantrips.assets.index code have control over.
- main/* main window. have control on code.
screenshot:
if @ stack, you'll see error not being thrown in code shown (which near bottom of stack), here:
diridchanged
@ assetindex.as:72
further down in stack you'll see following:
at flash.events::eventdispatcher/dispatchevent()
this means stack asynchronous in between assetdirectory.set id()
, assetindex.diridchanged()
when add event handler, code in current block run prior event handler code (as not in same thread).
so in case, code in try/catch
have run before event handler's code - why error not being caught.
any time handling event, need have try/catch, or use asynchronous error handling technique.
Comments
Post a Comment