throw new error - then what? - how does user get notice

Basic Tutorials concerning: GUI, Views, Activites, XML, Layouts, Intents, ...

throw new error - then what? - how does user get notice

Postby Mark Worsnop » Mon Dec 13, 2010 6:08 pm

I think I understand the

throw new error("this is an error");

but then what happens? I believe that tells the system that an error occured but if you want to alert the user to this, what is the point of the error() funtion?


try {

// something

} catch (IOException ioe) {

throw new Error( "Unable to access database");
}

where does the user get notified that something is wrong? If I want to just log the data then I could use Log.e() but would I also need the error()?
Mark Worsnop
Junior Developer
Junior Developer
 
Posts: 24
Joined: Wed Dec 01, 2010 12:34 am

Top

Re: throw new error - then what? - how does user get notice

Postby blundell » Wed Dec 15, 2010 10:09 am

Hi Mark,

I think you need to read up on some Java OO :-)

http://download.oracle.com/javase/tutor ... owing.html

the Error class ( http://developer.android.com/reference/ ... Error.html ) is just the SuperClass that all exceptions are created from, you shouldn't attempt to catch or throw it.

If you want to inform the user an exception has been raised you would do something.

Code: Select all

try {

// something

} catch (IOException ioe) {

new AlertDialog.Builder(this)
      .setTitle("Error")
      .setMessage("I broke sorry").show();

}

User avatar
blundell
Master Developer
Master Developer
 
Posts: 1610
Joined: Tue Nov 18, 2008 12:58 pm
Location: UK

Top

Return to Novice Tutorials

Who is online

Users browsing this forum: No registered users and 4 guests