UrbanPro

Learn Java Training from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

I want to rethrow an exception, is that possible?

Asked by Last Modified  

12 Answers

Learn Java

Follow 1
Answer

Please enter your answer

Professional Tutor with 15 years of experience.

yes we can
Comments

Trainer

If you develop your own library which makes use of a third-party library that throws an exception. Now there are two options for us: 1. don't catch it (not a better option) 2. catch it and log it somewhere, then rethrow it By rethrowing, we propgate this exception to the caller (client) of your...
read more
If you develop your own library which makes use of a third-party library that throws an exception. Now there are two options for us: 1. don't catch it (not a better option) 2. catch it and log it somewhere, then rethrow it By rethrowing, we propgate this exception to the caller (client) of your library and request it to catch the excpetion. This way your delegating the responsibility of handling this excpetion to the caller of our library read less
Comments

A software veteran with more than decade of experience

yes...you can use catch(Exception ex) { {some logic} throw ex; }
Comments

Java Tutor

yes...you can using catch block with appropriate Exception argument
Comments

Trainer

Yes, When you catch an exception, it's possible to rethrow it. This is just the same as if you hadn't caught it in the first place - the exception will continue to bubble up through the layers until it reaches some other code that catches it (or it reaches the top of the stack and the program exits)....
read more
Yes, When you catch an exception, it's possible to rethrow it. This is just the same as if you hadn't caught it in the first place - the exception will continue to bubble up through the layers until it reaches some other code that catches it (or it reaches the top of the stack and the program exits). So why would you do this? Well, it means you have temporary access to the exception at the point where you caught it. One situation I've used this in is where I want to log the fact that an error has occurred, but the real error handling is happening at a higher level. You'd only do this, though, if this local logging could add something useful that the higher level error handling doesn't know about. read less
Comments

Java Technical Leader

try { } catch(Exception ex) { }
Comments

Java Technical Leader

try { // code here } catch(Exception ex) { throw ex; } but this is not advisable hust catch the same exception and re-throw it. If you want to make your application specific message then you can try this.
Comments

Talent with Professional Experience

Yes you can rethrow an exception by throwing an exception inside catch block provided we are able to catch the Exception properly. If we are not sure what kind of Exception is caught; in that case we can catch the super Excepiton class incatch block and then throw any other exception
Comments

Java Web Application Development and Aptitude Trainer

yes you can.
Comments

Software Development Trainer

What do you mean by rethrow? Are you trying to ask if one can raise the exception again once it's handled in catch? If yes, then yeah we can. We need to use throw keyword. Something like this try{ //code } catch (exception ex) { //log the exception or do whatever you want. throw...
read more
What do you mean by rethrow? Are you trying to ask if one can raise the exception again once it's handled in catch? If yes, then yeah we can. We need to use throw keyword. Something like this try{ //code } catch (exception ex) { //log the exception or do whatever you want. throw ex;//rethrow exception } read less
Comments

View 10 more Answers

Related Questions

How do I show a popup message over a system tray icon/application in Java?
The java.awt.SystemTray class introduced in Java™ SE version 6 represents the system tray for a desktop. The system tray can be accessed by calling the static SystemTray.getSystemTray() method. Before...
Ajith
0 0
5
How to stop session hijacking programmatically ?
Encrypting the session value will have zero effect. The session cookie is already an arbitrary value, encrypting it will just generate another arbitrary value that can be sniffed. The only real solution...
Mnaohar S
Which programming language should I learn, C++, Python or Java?
It depend on your interest , meanwhile phython is the new boss. Java is evergreen
Navneet
0 0
5
in java every thing is in the form of object
Everything is object is java except primitive data types like int,long etc..thats the reason its not 100 % object oriented language..
Abrar
Hi, Can anyone help me on below queries? 1. What makes a class as "Thread safe class" ? 2. equals() method uses 3. Difference between String vs StringBuffer ?
There are three ways to construct thread-safe Java class which has some state: 1. Make it truly immutable 2.Make field volatile. 3.Use a synchronized block
Saurav

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons

Java : Compile-time Versus Runtime optimization
While designing and development, one should think in terms of compile-time and run-time.It helps in understanding language basics in a better way.Let's understand this with a question below : What...
S

Interview Tip : Q1) Why Strings are immutable in java ? What happen if it was mutable in java?
As we all know that Strings in java are immutabe in nature, now the question comes why the creator made it immutable in nature, although this field used maximum in any java program. The answer to this...

Spring - Dependency Injection (DI)
Spring - Dependency Injection (DI) DI is a framework which provides loose coupling in code. Here loose coupling means no hard coding of the object. Instead of hard coding, we will be injecting these object...

What Is Java? Explain The History Of Java
i. Ovierview: Java programming language was originally developed by Sun Microsystems which was initiated by James Gosling and released in 1995 as core component of Sun Microsystems' Java platform (Java...

Java Advantages
In this video, learn about Java and its advantages. Also, check out the difference between Java and C++, Java development kit, Java Run Time Environment (JRE) with a proper demonstration program for better clarity.

Recommended Articles

Designed in a flexible and user-friendly demeanor, Java is the most commonly used programming language for the creation of web applications and platform. It allows developers to “write once, run anywhere” (WORA). It is general-purpose, a high-level programming language developed by Sun Microsystem. Initially known as an...

Read full article >

Java is the most commonly used popular programming language for the creation of web applications and platform today. Integrated Cloud Applications and Platform Services Oracle says, “Java developers worldwide has over 9 million and runs approximately 3 billion mobile phones”.  Right from its first implication as java 1.0...

Read full article >

Java is the most famous programming language till date. 20 years is a big time for any programming language to survive and gain strength. Java has been proved to be one of the most reliable programming languages for networked computers. source:techcentral.com Java was developed to pertain over the Internet. Over...

Read full article >

In the domain of Information Technology, there is always a lot to learn and implement. However, some technologies have a relatively higher demand than the rest of the others. So here are some popular IT courses for the present and upcoming future: Cloud Computing Cloud Computing is a computing technique which is used...

Read full article >

Looking for Java Training Classes?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for Java Training Classes?

The best tutors for Java Training Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn Java Training with the Best Tutors

The best Tutors for Java Training Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more