package org.knowm.xchange.bitstamp.dto.trade;

import java.io.IOException;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.ObjectCodec;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonNode;

public class BitstampErrorDeserializer extends JsonDeserializer<String> {

  @Override
  public String deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {

    ObjectCodec oc = jsonParser.getCodec();
    JsonNode node = oc.readTree(jsonParser);
    if (node.isTextual()) {
      return node.textValue();
    } else if (node.isObject()) {
      JsonNode allNode = node.get("__all__");
      if (allNode != null && allNode.isArray()) {
        StringBuffer buf = new StringBuffer();
        for (JsonNode msgNode : allNode) {
          buf.append(msgNode.textValue());
          buf.append(",");
        }

        return buf.length() > 0 ? buf.substring(0, buf.length() - 1) : buf.toString();
      }

      return node.toString();
    }

    return null;
  }
}

@@ -119,67 +119,8 @@
 er;%0A
-import com.fasterxml.jackson.core.JsonProcessingException;%0A
 impo
@@ -536,33 +536,8 @@
 tion
-, JsonProcessingException
  %7B%0A%0A

delete unnecessary exception from throws list