Skip to content

Commit

Permalink
fix failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
graemerocher committed Feb 6, 2015
1 parent ac70860 commit c7f91f4
Showing 1 changed file with 14 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,19 +110,6 @@ trait ResponseRenderer extends WebAttributes {
}
}

/**
* Render the given {@link JSONElement} to the response
*
* @param json The JSON to render
*/
void render(JSONElement json) {
GrailsWebRequest webRequest = (GrailsWebRequest)RequestContextHolder.currentRequestAttributes()
HttpServletResponse response = webRequest.currentResponse

response.contentType = GrailsWebUtil.getContentType("application/json", DEFAULT_ENCODING)
renderWritable json, response
}

/**
* Use the given closure to render markup to the response. The markup is assumed to be HTML. Use {@link ResponseRenderer#render(java.util.Map, groovy.lang.Closure)} to change the content type.
*
Expand Down Expand Up @@ -379,10 +366,10 @@ trait ResponseRenderer extends WebAttributes {
}
}
catch (GroovyRuntimeException gre) {
throw new ControllerExecutionException("Error rendering template [" + templateName + "]: " + gre.getMessage(), gre)
throw new ControllerExecutionException("Error rendering template [$templateName]: ${gre.message}", gre)
}
catch (IOException ioex) {
throw new ControllerExecutionException("I/O error executing render method for arguments [" + argMap + "]: " + ioex.getMessage(), ioex)
throw new ControllerExecutionException("I/O error executing render method for arguments [$argMap]: ${ioex.message}" , ioex)
}
}
else if (argMap.containsKey(ARGUMENT_FILE)) {
Expand Down Expand Up @@ -423,7 +410,7 @@ trait ResponseRenderer extends WebAttributes {
SpringIOUtils.copy input, response.getOutputStream()
} catch (IOException e) {
throw new ControllerExecutionException(
"I/O error copying file to response: " + e.getMessage(), e)
"I/O error copying file to response: ${e.message}", e)
}
finally {
if (input) {
Expand All @@ -438,12 +425,18 @@ trait ResponseRenderer extends WebAttributes {
}
else if( !statusSet ) {
webRequest.renderView = false
applyContentType response, argMap, argMap
try {
response.writer.write argMap.inspect()
if(argMap instanceof JSONElement) {
response.contentType = GrailsWebUtil.getContentType(MimeType.JSON.name, DEFAULT_ENCODING)
renderWritable( (JSONElement)argMap, response )
}
catch (IOException e) {
throw new ControllerExecutionException("I/O error obtaining response writer: " + e.getMessage(), e)
else {
applyContentType response, argMap, argMap
try {
response.writer.write argMap.inspect()
}
catch (IOException e) {
throw new ControllerExecutionException("I/O error obtaining response writer: ${e.message}", e)
}
}
}
}
Expand Down

0 comments on commit c7f91f4

Please sign in to comment.