Catch error and exception (#1431)