Solved

Comparing Throwable

Posted on 2004-08-12
9
234 Views
Last Modified: 2013-12-29
I have this in my java code

Throwable t = Status.getException();

Status.getException returns OperationCanceledException.

Is there a way of comaring throwables like strings.

I want to check if the throwable is OperationCanceledException. IF yes.Put a message.


How do i accomplish this.



0
Comment
Question by:rashmi_be
  • 3
  • 2
9 Comments
 
LVL 5

Expert Comment

by:TrekkyLeaper
ID: 11784018
If i understand correctly, you just want to do this:

if( t instanceof OperationCanceledException ) {
  //do what you want if it is
} else {
  // do what you want if it isn't
}
0
 

Author Comment

by:rashmi_be
ID: 11784142
no t is not an instance of OperationCanceledException
0
 
LVL 5

Accepted Solution

by:
TrekkyLeaper earned 20 total points
ID: 11785919
t is a Throwable, but instanceof will check to see if the actual value (whatever was returned from the getException method call). If I am still misunderstanding, please post more information.
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 24

Expert Comment

by:sciuriware
ID: 11791018
TrekkyLeaper is right; read the books!
;JOOP!
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 12042199
ok
0
 
LVL 5

Expert Comment

by:TrekkyLeaper
ID: 12043151
Thanks, Venabili.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
table example 4 32
Custom Java Application connects to database: Which one of the 20? 4 35
check java version using powershell 13 182
java mysql insert application 14 29
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question