5757 * Wraps any runtime exceptions with a GrailsWrappedException instance.
5858 *
5959 * @author Graeme Rocher
60+ * @author Michael Yan
6061 */
6162@ SuppressWarnings ({ "rawtypes" , "unchecked" })
6263public class GrailsExceptionResolver extends SimpleMappingExceptionResolver implements ServletContextAware , GrailsApplicationAware {
@@ -263,7 +264,8 @@ protected String getRequestLogMessage(String exceptionName, HttpServletRequest r
263264
264265 sb .append (exceptionName )
265266 .append (" occurred when processing request: " )
266- .append ("[" ).append (request .getMethod ().toUpperCase ()).append ("] " );
267+ .append (LINE_SEPARATOR );
268+ sb .append ("URI: " );
267269
268270 if (request .getAttribute (WebUtils .FORWARD_REQUEST_URI_ATTRIBUTE ) != null ) {
269271 sb .append (request .getAttribute (WebUtils .FORWARD_REQUEST_URI_ATTRIBUTE ));
@@ -272,6 +274,13 @@ protected String getRequestLogMessage(String exceptionName, HttpServletRequest r
272274 sb .append (request .getRequestURI ());
273275 }
274276
277+ sb .append (LINE_SEPARATOR );
278+ sb .append ("Method: " ).append (request .getMethod ().toUpperCase ()).append (LINE_SEPARATOR );
279+
280+ if (message != null ) {
281+ sb .append ("Message: " ).append (message ).append (LINE_SEPARATOR );
282+ }
283+
275284 Config config = this .grailsApplication != null ? this .grailsApplication .getConfig () : null ;
276285 boolean shouldLogRequestParameters = config != null ? config .getProperty (Settings .SETTING_LOG_REQUEST_PARAMETERS ,
277286 Boolean .class , Environment .getCurrent () == Environment .DEVELOPMENT ) : false ;
@@ -282,9 +291,8 @@ protected String getRequestLogMessage(String exceptionName, HttpServletRequest r
282291 if (params .hasMoreElements ()) {
283292 String param ;
284293 String [] values ;
285- int i ;
286294
287- sb .append (" - parameters :" );
295+ sb .append ("Parameters :" );
288296
289297 List <String > blackList = (config .getProperty (Settings .SETTING_EXCEPTION_RESOLVER_PARAM_EXCLUDES ,
290298 List .class , Collections .emptyList ()));
@@ -296,28 +304,33 @@ protected String getRequestLogMessage(String exceptionName, HttpServletRequest r
296304 param = params .nextElement ();
297305 values = request .getParameterValues (param );
298306
299- if (values != null ) {
300- for (i = 0 ; i < values .length ; i ++) {
301- sb .append (LINE_SEPARATOR ).append (param ).append (": " );
307+ String paramName = param ;
308+ if (paramName .endsWith ("[]" )) {
309+ paramName = paramName .substring (0 , paramName .length () - 2 );
310+ }
302311
303- if (blackList .contains (param )) {
304- sb .append ("***" );
305- }
306- else {
307- sb .append (values [i ]);
308- }
312+ sb .append (LINE_SEPARATOR ).append (" - " ).append (paramName ).append (": " );
313+ if (values != null && values .length > 0 ) {
314+ if (blackList .contains (paramName )) {
315+ sb .append ("[FILTERED]" );
316+ }
317+ else {
318+ sb .append (String .join (", " , values ));
309319 }
310320 }
311321 }
322+
323+ sb .append (LINE_SEPARATOR );
312324 }
313325 }
314326
315327 sb .append (LINE_SEPARATOR );
316- if (message != null ) {
317- sb .append (message ).append (". " );
328+ if (this .stackFilterer .isShouldFilter ()) {
329+ sb .append ("Filtered stacktrace:" );
330+ }
331+ else {
332+ sb .append ("Full stacktrace:" );
318333 }
319- sb .append (LINE_SEPARATOR );
320- sb .append ("Stacktrace follows:" );
321334
322335 return sb .toString ();
323336 }
0 commit comments