All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.knowm.xchange.therock.dto.TheRockException Maven / Gradle / Ivy

package org.knowm.xchange.therock.dto;

import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
import java.util.Map;
import si.mazi.rescu.HttpStatusExceptionSupport;

public class TheRockException extends HttpStatusExceptionSupport {

  private List errors;

  protected TheRockException() {}

  public TheRockException(@JsonProperty("errors") List errors) {
    super(getFirstMessage(errors));
    this.errors = errors;
  }

  private static String getFirstMessage(List errors) {
    return errors == null || errors.isEmpty() ? null : errors.get(0).getMessage();
  }

  public List getErrors() {
    return errors;
  }

  public static class Error {
    private String message;
    private Integer code;
    private Map meta;

    public String getMessage() {
      return message;
    }

    public Integer getCode() {
      return code;
    }

    public Map getMeta() {
      return meta;
    }

    @Override
    public String toString() {
      return String.format("Error{message='%s', code=%d, meta=%s}", message, code, meta);
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy