Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6916729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:38:25+00:00 2026-05-27T09:38:25+00:00

I was trying to "intentionally" throw an error, by trying to access wrong URL

  • 0

I was trying to "intentionally" throw an error, by trying to access wrong URL as follows :

try 
{
var myData:URLRequest = new URLRequest("http://www.abc.com/");
myData.method = URLRequestMethod.POST;
var vars:URLVariables = new URLVariables();

var loader:URLLoader = new URLLoader();
 loader.load(myData); 
}
catch(e:Error)
{
   trace("Yess!, caught it!");
}

The above code, couldnot catch any error!

Later i found that, there are two packages as follows :

flash.errors.IOError;

flash.events.IOErrorEvent;

so i figured out that it should have an addEventListener as follows :
loader.addEventListener(IOErrorEvent.IO_ERROR, errorOccured);

But it left me wondering, why i have to listen an event for an error. Why can’t i just make use of try and catch. Why two ways of error handling, one by try-catch another by listening an event? .

Thanks
V.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T09:38:26+00:00Added an answer on May 27, 2026 at 9:38 am

    You can’t use a try-catch on the URLLoader load method because the load method works asynchronously; Code execution does not suspend until the download finishes. This is typically how the Flash Player engine works. Asynchronous methods that can fail will dispatch error events, while synchronous methods that can fail will throw exceptions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to get the XPath "/deployment/service". Tested on this site: http://www.xmlme.com/XpathTool.aspx <?xml
Trying the following method to open an Arabic URL: String cmd = "cmd.exe /C
I am trying to update some object properties by calling UpdateModel(myObject, new[] { "stringprop1",
I get an error saying "Compilation failed: unmatched parentheses at offset 11" while trying
I am trying to do "POST" with XMLHttpRequest in a firefox extension, and after
I'm trying to find a way to "pretty print" a JavaScript data structure in
I have been trying to use the Perl utility/module "prove" as a test harness
I am trying to implement a feature similar to the "Related Questions" on Stackoverflow.
I am trying to extract the content of a single "value" attribute in a
Trying to mount a device and get the pid of mount command. cmd="/bin/mount /dev/sda1

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.