I want to throw a run-time exception from a method which will be caught in another class, which in turn throws a further specific custom exception or does some operation.
def checkExtension(String fileName,file) {
String [] arr= Holders.config.bdmserver.defaultfile_ext
for (int i=0; i < arr.length-1;i++) {
println("file extension=" + fileName.substring(fileName.length() - 3))
if (arr[i].equals(fileName.substring(fileName.length() - 4))) {
println("in if becoz its either .zip or .exe")
// throw run-time exception
}
}
def fileSize = (file.getSize())/12000
if (fileSize > 5 ){
// throw run-time exception
}
}
in different class
catch (run-time exception ex){
throw new ApplicationException(BdmsException, messageSource.getMessage("file.upload.failureExtension.message", "Error!! you can not upload a file with this extension", Locale.getDefault()), ex)
}
How can I do it without creating a new custom exception class?