/*
 * (C) Copyright 2013 Kurento (http://kurento.org/)
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser General Public License
 * (LGPL) version 2.1 which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/lgpl-2.1.html
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 */
package org.kurento.jsonrpc;

import org.kurento.jsonrpc.message.ResponseError;

import com.google.gson.JsonElement;

public class JsonRpcErrorException extends JsonRpcException {

	private static final long serialVersionUID = 1584953670536766280L;

	private final ResponseError error;

	public JsonRpcErrorException(int code, String message) {
		this(new ResponseError(code, message));
	}

	public JsonRpcErrorException(int code, String message, JsonElement data) {
		this(new ResponseError(code, message, data));
	}
	
	public JsonRpcErrorException(int code, String message, Exception e) {
		this(ResponseError.newFromException(e));
	}

	public JsonRpcErrorException(ResponseError error) {
		super(createExceptionMessage(error));
		this.error = error;
	}

	private static String createExceptionMessage(ResponseError error) {
		return error.getMessage()
				+ ((error.getData() != null) ? (". Data: " + error.getData())
						: "");
	}

	public ResponseError getError() {
		return error;
	}

	public String getData() {
		return error.getData();
	}

	public int getCode() {
		return error.getCode();
	}

	public String getServerMessage() {
		return error.getMessage();
	}

}

@@ -1408,30 +1408,43 @@
  error) %7B%0A%09%09
-return
+%0A%09%09String message =
  error.getMe
@@ -1454,16 +1454,94 @@
 ge()
+;
 %0A%09%09
+%0A
 %09%09
-+ (
+if(error.getCode() != 0)%7B%0A%09%09%09message += %22. Code: %22+error.getCode();%0A%09%09%7D%0A%09%09%0A%09%09if
 (err
@@ -1565,12 +1565,24 @@
 ull)
- ? (
+%7B%0A%09%09%09message += 
 %22. D
@@ -1609,21 +1609,33 @@
 ta()
-)
+;
 %0A%09%09
+%7D%0A
 %09%09
+%0A
 %09%09
-: %22%22)
+return message
 ;%0A%09%7D

Include code in JsonRpcErrorException error message