Take into consideration that in normal REST development, there isn't need to set the view to "error" and put an error message as the status is enough, but this makes troubleshooting problems using a browser much easier during initial REST development phase.
def setStatusNotFound(id){
logger.FINER {"Start"};
//Construct error
request.view="error";
request.status=HttpURLConnection.HTTP_NOT_FOUND;
request.header.out."Content-Type"= "text/html";
request.error.message="Object with ID ${id} is not found";
render();
logger.FINER {"End"};
}
def setInternalServerError(ex){
logger.INFO {"Start"};
//Construct error
request.view="error";
request.status=HttpURLConnection.HTTP_INTERNAL_ERROR;
request.header.out."Content-Type"= "text/html";
request.error.message="Application internal error\n";
request.error.message+=ex.message;
//request.error.exception="test";
render();
logger.FINER {"End"};
}
No comments:
Post a Comment