001/*
002 * acme4j - Java ACME client
003 *
004 * Copyright (C) 2016 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.time.Instant;
017import java.util.Objects;
018
019/**
020 * This exception is thrown when a server side process has not been completed yet, and the
021 * server returned an estimated retry date.
022 */
023public class AcmeRetryAfterException extends AcmeException {
024    private static final long serialVersionUID = 4461979121063649905L;
025
026    private final Instant retryAfter;
027
028    /**
029     * Creates a new {@link AcmeRetryAfterException}.
030     *
031     * @param msg
032     *            Error details
033     * @param retryAfter
034     *            retry-after date returned by the server
035     */
036    public AcmeRetryAfterException(String msg, Instant retryAfter) {
037        super(msg);
038        this.retryAfter = Objects.requireNonNull(retryAfter);
039    }
040
041    /**
042     * Returns the retry-after date returned by the server.
043     */
044    public Instant getRetryAfter() {
045        return retryAfter;
046    }
047
048}