Anna daadson
Anna daadson

Reputation: 11

Unhandled exception error, android

I fetch my json object to the function but I have unhandled exception error, is anyone knows about this problem, appreciated sample code!

Thanks!

//Here is the error, when I want to fetch the object = jsonObj //acctually the error is in the code I cann't run it, it's a red line from //TestValidator.validateDateWithCriteria(testCriteria, jsonObj);

   return TestValidator.TestWithCriteria(testCriteria, jsonObj);
}

Upvotes: 0

Views: 414

Answers (1)

panini
panini

Reputation: 2026

In your definition of DateValidator#validateDateWithCriteria() you have said that it throws an Exception.

However, when you call the method, you aren't putting it in a try/catch block. Because you have said you will throw an Exception, you must attempt to catch this potential Exception whenever you call the method. for example:

try{
     return DateValidator.validateDateWithCriteria(validationCriteria, jsonObj);
}catch(Exception ex){
    Log.e("Your Tag", "DateValidator", ex);
    return null;
}

Upvotes: 2

Related Questions