001/* 002 * acme4j - Java ACME client 003 * 004 * Copyright (C) 2015 Richard "Shred" Körber 005 * http://acme4j.shredzone.org 006 * 007 * Licensed under the Apache License, Version 2.0 (the "License"); 008 * you may not use this file except in compliance with the License. 009 * 010 * This program is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 013 */ 014package org.shredzone.acme4j.exception; 015 016import java.net.URI; 017import java.util.Objects; 018 019import org.shredzone.acme4j.Problem; 020 021/** 022 * The ACME server returned an error. The exception contains a {@link Problem} document 023 * containing the exact cause of the error. 024 * <p> 025 * For some special cases, subclasses of this exception are thrown, so they can be handled 026 * individually. 027 */ 028public class AcmeServerException extends AcmeException { 029 private static final long serialVersionUID = 5971622508467042792L; 030 031 private final Problem problem; 032 033 /** 034 * Creates a new {@link AcmeServerException}. 035 * 036 * @param problem 037 * {@link Problem} that caused the exception 038 */ 039 public AcmeServerException(Problem problem) { 040 super(Objects.requireNonNull(problem).toString()); 041 this.problem = problem; 042 } 043 044 /** 045 * Returns the error type. 046 */ 047 public URI getType() { 048 return problem.getType(); 049 } 050 051 /** 052 * Returns the {@link Problem} that caused the exception 053 */ 054 public Problem getProblem() { 055 return problem; 056 } 057 058}