// Path: src/main/java/dk/clanie/bitcoin/client/response/BitcoindErrorResponse.java
// @SuppressWarnings("serial")
// @RooJavaBean(settersByDefault = false)
// public class BitcoindErrorResponse extends BitcoindJsonRpcResponse<Object> {
// 
// }
// 
// Path: src/main/java/dk/clanie/bitcoin/exception/BitcoinException.java
// @SuppressWarnings("serial")
// public class BitcoinException extends AbstractRuntimeException {
// 
// 	private BitcoindErrorResponse errorResponse = null;
// 
// 
// 	protected BitcoinException(BitcoindErrorResponse errorResponse) {
// 		super(errorResponse.getError().getMessage());
// 		this.errorResponse = errorResponse;
// 	}
// 
// 
// 	public BitcoinException(Exception cause) {
// 		super(cause);
// 	}
// 	
// 
// 	public BitcoinException(String message, Exception cause) {
// 		super(message, cause);
// 	}
// 	
// 
// 	/**
// 	 * Gets the whole response received from bitcoind.
// 	 * 
// 	 * @return {@link BitcoindErrorResponse} - may be null.
// 	 */
// 	public BitcoindErrorResponse getErrorResponse() {
// 		return errorResponse;
// 	}
// 
// 
// 	/**
// 	 * Gets the error code received from bitcoind.
// 	 * 
// 	 * @return errorcode or null if no error code was received.
// 	 */
// 	public Integer getErrorCode() {
// 		if (errorResponse == null || errorResponse.getError() == null) return null;
// 		return errorResponse.getError().getCode();
// 	}
// 
// 
// 	@Override
// 	public String toString() {
// 		return ToStringBuilder.reflectionToString(this);
// 	}
// 
// 
// }
// 
// Path: src/main/java/dk/clanie/bitcoin/exception/client/BitcoinClientException.java
// @SuppressWarnings("serial")
// public class BitcoinClientException extends BitcoinException {
// 
// 	public BitcoinClientException(BitcoindErrorResponse errorResponse) {
// 		super(errorResponse);
// 	}
// 
// }
// 
// Path: src/main/java/dk/clanie/bitcoin/exception/client/MethodNotFoundException.java
// @SuppressWarnings("serial")
// public class MethodNotFoundException extends BitcoinClientException {
// 
// 
// 	public MethodNotFoundException(BitcoindErrorResponse errorResponse) {
// 		super(errorResponse);
// 	}
// 
// 	
// }
// 
// Path: src/main/java/dk/clanie/bitcoin/exception/server/BitcoinServerException.java
// @SuppressWarnings("serial")
// public class BitcoinServerException extends BitcoinException {
// 
// 	public BitcoinServerException(BitcoindErrorResponse errorResponse) {
// 		super(errorResponse);
// 	}
// 
// }
// 
// Path: src/main/java/dk/clanie/bitcoin/exception/server/InvalidAddressException.java
// @SuppressWarnings("serial")
// public class InvalidAddressException extends BitcoinServerException {
// 
// 
// 	public InvalidAddressException(BitcoindErrorResponse errorResponse) {
// 		super(errorResponse);
// 	}
// 
// 	
// }
// 
// Path: src/main/java/dk/clanie/bitcoin/exception/server/WalletEncryptionException.java
// @SuppressWarnings("serial")
// public class WalletEncryptionException extends BitcoinServerException {
// 
// 
// 	public WalletEncryptionException(BitcoindErrorResponse errorResponse) {
// 		super(errorResponse);
// 	}
// 
// 	
// }


import dk.clanie.bitcoin.client.response.BitcoindErrorResponse;
import dk.clanie.bitcoin.exception.BitcoinException;
import dk.clanie.bitcoin.exception.client.BitcoinClientException;
import dk.clanie.bitcoin.exception.client.MethodNotFoundException;
import dk.clanie.bitcoin.exception.server.BitcoinServerException;
import dk.clanie.bitcoin.exception.server.InvalidAddressException;
import dk.clanie.bitcoin.exception.server.WalletEncryptionException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.client.ClientHttpResponse;
import org.springframework.util.FileCopyUtils;
import org.springframework.web.client.DefaultResponseErrorHandler;
import org.springframework.web.client.UnknownHttpStatusCodeException;
import com.fasterxml.jackson.databind.ObjectMapper;
				// Error: Please enter the wallet passphrase with walletpassphrase first.
				throw new BitcoinServerException(errorResponse);
			case -14:
				// Error: The wallet passphrase entered was incorrect.
				throw new BitcoinServerException(errorResponse);
			case -15:
				// Error: running with an unencrypted wallet, but walletpassphrasechange was called.
				// Error: running with an encrypted wallet, but encryptwallet was called.
				throw new WalletEncryptionException(errorResponse);
			case -17:
				// Error: Wallet is already unlocked.
				throw new BitcoinServerException(errorResponse);
			default:
				throw new BitcoinServerException(errorResponse);
			}
		}
		case CLIENT_ERROR: {
			BitcoindErrorResponse errorResponse = parseResponse(response, statusCode);
			switch (errorResponse.getError().getCode()) {
			case -32601:
				// Method not found
				throw new MethodNotFoundException(errorResponse);
			default:
				throw new BitcoinClientException(errorResponse);
			}
		}
		default:
			try {
				super.handleError(response);
			} catch (Exception cause) {
// Path: src/main/java/dk/clanie/bitcoin/client/response/BitcoindErrorResponse.java
// @SuppressWarnings("serial")
// @RooJavaBean(settersByDefault = false)
// public class BitcoindErrorResponse extends BitcoindJsonRpcResponse<Object> {
// 
// }
// 
// Path: src/main/java/dk/clanie/bitcoin/exception/BitcoinException.java
// @SuppressWarnings("serial")
// public class BitcoinException extends AbstractRuntimeException {
// 
// 	private BitcoindErrorResponse errorResponse = null;
// 
// 
// 	protected BitcoinException(BitcoindErrorResponse errorResponse) {
// 		super(errorResponse.getError().getMessage());
// 		this.errorResponse = errorResponse;
// 	}
// 
// 
// 	public BitcoinException(Exception cause) {
// 		super(cause);
// 	}
// 	
// 
// 	public BitcoinException(String message, Exception cause) {
// 		super(message, cause);
// 	}
// 	
// 
// 	/**
// 	 * Gets the whole response received from bitcoind.
// 	 * 
// 	 * @return {@link BitcoindErrorResponse} - may be null.
// 	 */
// 	public BitcoindErrorResponse getErrorResponse() {
// 		return errorResponse;
// 	}
// 
// 
// 	/**
// 	 * Gets the error code received from bitcoind.
// 	 * 
// 	 * @return errorcode or null if no error code was received.
// 	 */
// 	public Integer getErrorCode() {
// 		if (errorResponse == null || errorResponse.getError() == null) return null;
// 		return errorResponse.getError().getCode();
// 	}
// 
// 
// 	@Override
// 	public String toString() {
// 		return ToStringBuilder.reflectionToString(this);
// 	}
// 
// 
// }
// 
// Path: src/main/java/dk/clanie/bitcoin/exception/client/BitcoinClientException.java
// @SuppressWarnings("serial")
// public class BitcoinClientException extends BitcoinException {
// 
// 	public BitcoinClientException(BitcoindErrorResponse errorResponse) {
// 		super(errorResponse);
// 	}
// 
// }
// 
// Path: src/main/java/dk/clanie/bitcoin/exception/client/MethodNotFoundException.java
// @SuppressWarnings("serial")
// public class MethodNotFoundException extends BitcoinClientException {
// 
// 
// 	public MethodNotFoundException(BitcoindErrorResponse errorResponse) {
// 		super(errorResponse);
// 	}
// 
// 	
// }
// 
// Path: src/main/java/dk/clanie/bitcoin/exception/server/BitcoinServerException.java
// @SuppressWarnings("serial")
// public class BitcoinServerException extends BitcoinException {
// 
// 	public BitcoinServerException(BitcoindErrorResponse errorResponse) {
// 		super(errorResponse);
// 	}
// 
// }
// 
// Path: src/main/java/dk/clanie/bitcoin/exception/server/InvalidAddressException.java
// @SuppressWarnings("serial")
// public class InvalidAddressException extends BitcoinServerException {
// 
// 
// 	public InvalidAddressException(BitcoindErrorResponse errorResponse) {
// 		super(errorResponse);
// 	}
// 
// 	
// }
// 
// Path: src/main/java/dk/clanie/bitcoin/exception/server/WalletEncryptionException.java
// @SuppressWarnings("serial")
// public class WalletEncryptionException extends BitcoinServerException {
// 
// 
// 	public WalletEncryptionException(BitcoindErrorResponse errorResponse) {
// 		super(errorResponse);
// 	}
// 
// 	
// }


// Path: src/main/java/dk/clanie/bitcoin/client/BitcoindJsonRpcErrorHandler.java
import dk.clanie.bitcoin.client.response.BitcoindErrorResponse;
import dk.clanie.bitcoin.exception.BitcoinException;
import dk.clanie.bitcoin.exception.client.BitcoinClientException;
import dk.clanie.bitcoin.exception.client.MethodNotFoundException;
import dk.clanie.bitcoin.exception.server.BitcoinServerException;
import dk.clanie.bitcoin.exception.server.InvalidAddressException;
import dk.clanie.bitcoin.exception.server.WalletEncryptionException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.client.ClientHttpResponse;
import org.springframework.util.FileCopyUtils;
import org.springframework.web.client.DefaultResponseErrorHandler;
import org.springframework.web.client.UnknownHttpStatusCodeException;
import com.fasterxml.jackson.databind.ObjectMapper;

				// Error: Please enter the wallet passphrase with walletpassphrase first.
				throw new BitcoinServerException(errorResponse);
			case -14:
				// Error: The wallet passphrase entered was incorrect.
				throw new BitcoinServerException(errorResponse);
			case -15:
				// Error: running with an unencrypted wallet, but walletpassphrasechange was called.
				// Error: running with an encrypted wallet, but encryptwallet was called.
				throw new WalletEncryptionException(errorResponse);
			case -17:
				// Error: Wallet is already unlocked.
				throw new BitcoinServerException(errorResponse);
			default:
				throw new BitcoinServerException(errorResponse);
			}
		}
		case CLIENT_ERROR: {
			BitcoindErrorResponse errorResponse = parseResponse(response, statusCode);
			switch (errorResponse.getError().getCode()) {
			case -32601:
				// Method not found
				throw new MethodNotFoundException(errorResponse);
			default:
				throw new BitcoinClientException(errorResponse);
			}
		}
		default:
			try {
				super.handleError(response);
			} catch (Exception cause) {
				throw new BitcoinException(cause);