code: public static ResponseBuilder handleError( int status, RestError restError, String lang ) {
  
  		List<RoboconfError> errors = new ArrayList<> ();
  		errors.add( restError );
  		if( restError.getException() instanceof InvalidApplicationException ) {
  			errors.addAll(((InvalidApplicationException) restError.getException()).getErrors());
  		}
  
  		StringBuilder sb = new StringBuilder();
  		String sep = "\n\n";
  		for( String s : RoboconfErrorHelpers.formatErrors( errors, null, false ).values()) {
  			sb.append( s );
  			sb.append( sep );
  			sep = "\n";
  		}
  
  		// Errors should return a JSon object.
  		// Otherwise, Restangular cannot parse error messages.
  		// See https://stackoverflow.com/questions/42068/how-do-i-handle-newlines-in-json
  		String msg = sb.toString().trim()
  						.replaceAll( "\"", "\\\"" )
  						.replaceAll( "\n", "\\\\n" )
  						.replaceAll( "\r", "\\\\r" )
  						.replaceAll( "\t", "\\\\t" );
  
  		return Response.status( status ).entity( "{\"reason\":\"" + msg + "\"}" );
  	}
docs: Handles an error and makes the magic stuff so that users can understand it.
  @param status the response's status
  @param restError a REST error
  @param lang the user language
  @return a response builder