John Doe 12345 67890 ; statusText.text = "Click the Validate button to check the XML"; hideButtons(); } public function validateData():void { try { var tempXML:XML = XML(xmlText.text); actionscript_book_CustomErrors_com_example_programmingas3_errors_Validator.validateEmployeeXML(tempXML); statusText.text = "The XML was successfully validated."; } catch (error:actionscript_book_CustomErrors_com_example_programmingas3_errors_FatalError) { showFatalError(error); } catch (error:actionscript_book_CustomErrors_com_example_programmingas3_errors_WarningError) { showWarningError(error); } catch (error:Error) { showGenericError(error); } } public function showFatalError(error:actionscript_book_CustomErrors_com_example_programmingas3_errors_FatalError):void { var message:String = error.message + "\n\n"; var title:String = error.getTitle(); statusText.text = message + " " + title + "\n\nThis application has ended."; this.xmlText.enabled = false; this.validateBtn.enabled = false; hideButtons(); } public function showWarningError(error:actionscript_book_CustomErrors_com_example_programmingas3_errors_WarningError):void { var message:String = error.message + "\n\n" + "Do you want to exit this application?"; showButtons(); var title:String = error.getTitle(); statusText.text = message; } public function showGenericError(error:Error):void { statusText.text = error.message + "\n\nEncountered an unknown error: " + error.name; } private function showButtons():void { yesButton.visible = true; noButton.visible = true; } private function hideButtons():void { yesButton.visible = false; noButton.visible = false; } private function closeHandler(event:MouseEvent):void { switch (event.target) { case yesButton: showFatalError(new actionscript_book_CustomErrors_com_example_programmingas3_errors_FatalError(9999)); break; case noButton: statusText.text = ""; hideButtons(); break; } } ]]>