Better exception handling for REST api