Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 253
  • Last Modified:

Comparing Throwable

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
rashmi_be
Asked:
rashmi_be
  • 3
  • 2
1 Solution
 
TrekkyLeaperCommented:
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
 
rashmi_beAuthor Commented:
no t is not an instance of OperationCanceledException
0
 
TrekkyLeaperCommented:
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
sciuriwareCommented:
TrekkyLeaper is right; read the books!
;JOOP!
0
 
sciuriwareCommented:
ok
0
 
TrekkyLeaperCommented:
Thanks, Venabili.
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now