001/*
002 *  Copyright 2026 Anyware Services
003 *
004 *  Licensed under the Apache License, Version 2.0 (the "License");
005 *  you may not use this file except in compliance with the License.
006 *  You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 *  Unless required by applicable law or agreed to in writing, software
011 *  distributed under the License is distributed on an "AS IS" BASIS,
012 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 *  See the License for the specific language governing permissions and
014 *  limitations under the License.
015 */
016package org.ametys.web.repository.site;
017
018/**
019 * Exception related to a {@link Site}
020 */
021public class SiteException extends Exception
022{
023    private Type _type;
024    
025    /**
026     * The type of the exception.
027     */
028    public enum Type
029    {
030        /** The name of site is not authorized */
031        UNAUTHORIZED_SITENAME,
032        /** A site with the name already exists */
033        ALREADY_EXIST,
034        /** Unknown error */
035        UNKNOWN;
036    }
037    
038    /**
039     * Constructs a new SiteException.
040     */
041    public SiteException()
042    {
043        super();
044        _type = Type.UNKNOWN;
045    }
046    
047    /**
048     * Constructs a new SiteException with the specified message.
049     * @param message the message of the exception.
050     */
051    public SiteException(String message)
052    {
053        super(message);
054        _type = Type.UNKNOWN;
055    }
056    
057    /**
058     * Constructs a new SiteException with the specified message.
059     * @param message the message of the exception.
060     * @param type the type of the exception
061     */
062    public SiteException(String message, Type type)
063    {
064        super(message);
065        _type = type;
066    }
067    
068    /**
069     * Constructs a new SiteException with the specified message and cause.
070     * @param message the message of the exception.
071     * @param cause the cause of the exception.
072     */
073    public SiteException(String message, Throwable cause)
074    {
075        super(message, cause);
076        _type = Type.UNKNOWN;
077    }
078    
079    /**
080     * Constructs a new SiteException with the specified message and cause.
081     * @param message the message of the exception.
082     * @param cause the cause of the exception.
083     * @param type the type of the exception
084     */
085    public SiteException(String message, Throwable cause, Type type)
086    {
087        super(message, cause);
088        _type = type;
089    }
090    
091    /**
092     * Constructs a new SiteException with the specified cause.
093     * @param cause the cause of the exception.
094     */
095    public SiteException(Throwable cause)
096    {
097        super(cause);
098        _type = Type.UNKNOWN;
099    }
100    
101    /**
102     * Constructs a new SiteException with the specified cause.
103     * @param cause the cause of the exception.
104     * @param type the type of the exception
105     */
106    public SiteException(Throwable cause, Type type)
107    {
108        super(cause);
109        _type = type;
110    }
111    
112    /**
113     * Get the type of the exception
114     * @return the type
115     */
116    public Type getType()
117    {
118        return _type;
119    }
120
121}