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

com.xeiam.xchange.therock.dto.TheRockException Maven / Gradle / Ivy

The newest version!
package com.xeiam.xchange.therock.dto;

import java.util.List;
import java.util.Map;

import com.fasterxml.jackson.annotation.JsonProperty;

import si.mazi.rescu.HttpStatusExceptionSupport;

public class TheRockException extends HttpStatusExceptionSupport {

  private List errors;

  public List getErrors() {
    return 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 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 - 2025 Weber Informatics LLC | Privacy Policy