Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

If you don't really care of the exception which are thrown inside your try block, you can simply catch any of them and simply omit the type of the caught exception. So instead of catching the throwables exceptions like in:

Code Block
try {
    // ...
} catch (ThrowableException t) {
    // something bad happens
}

...

Code Block
try {
    // ...
} catch (any) {
    // something bad happens
}
Info
Note that it's catching all Exceptions, not Throwables. If you need to really catch "everything", you'll have to be explicit and say you want to catch Throwables.

Optional typing advice

I'll finish on some words on when and how to use optional typing. Groovy lets you decide whether you use explicit strong typing, or when you use 'def'.

...