Is there a way to throw an exception without adding the throws declaration?

You can throw unchecked exceptions without having to declare them if you really want to. Unchecked exceptions extend RuntimeException. Throwables that extend Error are also unchecked, but should only be used for completely un-handleable issues (such as invalid bytecode or out of memory).

As a specific case, Java 8 added UncheckedIOException for wrapping and rethrowing IOException.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)