Better support of exceptions for the API