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

What is the difference between string, stringbuffer, stringbuilder?
String is immutable, means once you created a String you can not modify, Even if you try to it will create a new string for you and assign that to you. StringBuffer and StringBuilder are immutable, however...
Neha
Please suggest some books to self-learn Java at home?
For self learning the best book is Core Java written by Gary Cornell and Kay Horstmann. This book comes in 2 volumes and both are important to learn the subject from the ground up to the advanced level.
Sharmistha
1 0
6
Can Anybody explain Internal code of HashMap?
Now we can synchronize map also by using collections. Synchronize method need to pass map Object as parameter...
Ramakanth
When we are used the compiler and interpreter? what is the difference between them?
Java code is the best example of compiled as well as interpreted. Java Compiler does the task of compiling . Java file to .class file(binary form). JVM works as interpreter to let Operating system understand the compiled code instructions.
Shilpa
Write a programme to replace the string without using replace command? This is my string. ..... s is replaced by th output is Thith ith my thtring
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package logic; ...
Mithun

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

Ask a Question

Related Lessons

Syntax and example of java
Java syntax: Class Display - - class definition { Void Display() { System.out.println('welcome to Java') ; } Public static void main(String arcs) { Display D=new Display() ;--object creation D. Display } }

How can everyone prepare to clear any Java interview?
Java interview your java should be much strong then J2EE. core java and Advance java is the basic foundation for Interview. Some of the topic about which you should know before going for a java interview...

Why We Should Go With Java?
Java is widely used in the Desktop application, web application, mobile development, games etc. Java is an object-oriented programming language. Its follow all the oops concept Like Object, Class,...
B

Bhupendra Patidar

0 0
0

Android : Support multiple themes in an android application
If you are developing a theme based application to enhance user experience, then following steps needs to follow.We are taking example of an android application having 2 themes white and black.Step 1:Define...

Why Should We Learn Java Language?
Most of starters has confusion today that which of the programming language should be chosen to work on. It totally depends upon your need. As per my opinion, if you want to grow your career in IT industry...

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