Jobs
Jobs

Reputation: 1315

Cassandra Error Handling

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?

Upvotes: 3

Views: 2618

Answers (1)

Andy Tolbert
Andy Tolbert

Reputation: 11638

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.

Upvotes: 4

Related Questions