Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cassandra Error Handling

Tags:

cassandra

The session.execute() portion of my Cassandra client does not prompt any error handling prompt in eclipse.

session.execute(batch); 

Should I manually do try catch .

try
{
session.execute(batch); 
}
catch(Exception e)
{
// Handle error here
}

If yes, Should I handle each error related to query execution separately?

like image 640
Jobs Avatar asked Feb 15 '26 18:02

Jobs


1 Answers

NoHostAvailableException, QueryExecutionException, QueryValidationException, and UnsupportedFeatureException all extend DriverException which is a RuntimeException which is an unchecked exception. From the javadoc for RuntimeException:

RuntimeException and its subclasses are unchecked exceptions. Unchecked exceptions do not need to be declared in a method or constructor's throws clause if they can be thrown by the execution of the method or constructor and propagate outside the method or constructor boundary.

This is why eclipse doesn't give you a compiler error when you don't handle session.execute with a try catch or throws declaration in your method signature.

like image 62
Andy Tolbert Avatar answered Feb 17 '26 17:02

Andy Tolbert