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.io.Serial; 017import java.net.URI; 018import java.util.Objects; 019 020import org.shredzone.acme4j.Problem; 021 022/** 023 * The ACME server returned an error. The exception contains a {@link Problem} document 024 * containing the exact cause of the error. 025 * <p> 026 * For some special cases, subclasses of this exception are thrown, so they can be handled 027 * individually. 028 */ 029public class AcmeServerException extends AcmeException { 030 @Serial 031 private static final long serialVersionUID = 5971622508467042792L; 032 033 private final Problem problem; 034 035 /** 036 * Creates a new {@link AcmeServerException}. 037 * 038 * @param problem 039 * {@link Problem} that caused the exception 040 */ 041 public AcmeServerException(Problem problem) { 042 super(Objects.requireNonNull(problem).toString()); 043 this.problem = problem; 044 } 045 046 /** 047 * Returns the error type. 048 */ 049 public URI getType() { 050 return problem.getType(); 051 } 052 053 /** 054 * Returns the {@link Problem} that caused the exception 055 */ 056 public Problem getProblem() { 057 return problem; 058 } 059 060}