001/*
002 * The contents of this file are subject to the terms of the Common Development and
003 * Distribution License (the License). You may not use this file except in compliance with the
004 * License.
005 *
006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
007 * specific language governing permission and limitations under the License.
008 *
009 * When distributing Covered Software, include this CDDL Header Notice in each file and include
010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
011 * Header, with the fields enclosed by brackets [] replaced by your own identifying
012 * information: "Portions Copyright [year] [name of copyright owner]".
013 *
014 * Copyright 2016 ForgeRock AS.
015 */
016package org.opends.server.protocols.http;
017
018import org.forgerock.http.HttpApplicationException;
019import org.forgerock.i18n.LocalizableException;
020import org.forgerock.i18n.LocalizableMessage;
021
022/**
023 * Thrown to indicate that an {@link HttpApplication} was unable to start. A {@code LocalizedHttpApplicationException}
024 * contains a localized error message which may be used to provide the user with detailed diagnosis information. The
025 * localized message can be retrieved using the {@link #getMessageObject} method.
026 */
027public class LocalizedHttpApplicationException extends HttpApplicationException implements LocalizableException
028{
029  private static final long serialVersionUID = 2150656895248806504L;
030
031  private final LocalizableMessage message;
032
033  /**
034   * Creates a new localized http application exception with the provided message.
035   *
036   * @param message
037   *          The message that explains the problem that occurred.
038   */
039  public LocalizedHttpApplicationException(LocalizableMessage message)
040  {
041    super(message.toString());
042    this.message = message;
043  }
044
045  /**
046   * Creates a new localized http application exception with the provided message and cause.
047   *
048   * @param message
049   *          The message that explains the problem that occurred.
050   * @param cause
051   *          The cause which may be later retrieved by the {@link #getCause} method. A {@code null} value is permitted,
052   *          and indicates that the cause is nonexistent or unknown.
053   */
054  public LocalizedHttpApplicationException(LocalizableMessage message, Throwable cause)
055  {
056    super(message.toString(), cause);
057    this.message = message;
058  }
059
060  @Override
061  public final LocalizableMessage getMessageObject()
062  {
063    return message;
064  }
065}