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.URL;
017import java.util.Objects;
018
019/**
020 * An exception that is thrown when there is a conflict with the request. For example,
021 * this exception is thrown when a registration already exists.
022 */
023public class AcmeConflictException extends AcmeException {
024    private static final long serialVersionUID = 7454201988845449591L;
025
026    private final URL location;
027
028    /**
029     * Creates a new {@link AcmeConflictException}.
030     *
031     * @param msg
032     *            Details about the conflicting resource
033     * @param location
034     *            {@link URL} of the conflicting resource
035     */
036    public AcmeConflictException(String msg, URL location) {
037        super(msg);
038        this.location = Objects.requireNonNull(location, "location");
039    }
040
041    /**
042     * Location of the conflicting resource.
043     */
044    public URL getLocation() {
045        return location;
046    }
047
048}