/*
 * This file is a part of EpnTAPClient.
 * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer.
 * See draft specifications: https://voparis-confluence.obspm.fr/pages/viewpage.action?pageId=559861
 * Copyright (C) 2016 Institut de Recherche en Astrophysique et Planétologie.
 *
 * This program is free software: you can
 * redistribute it and/or modify it under the terms of the GNU General Public License as published
 * by the Free Software Foundation, either version 3 of the License, or (at your option) any later
 * version. This program is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 * PURPOSE. See the GNU General Public License for more details. You should have received a copy of
 * the GNU General Public License along with this program. If not, see
 * <http://www.gnu.org/licenses/>.
 */

package eu.omp.irap.vespa.epntapclient.voresource;

/**
 * The general abstract class for all exceptions concerning the VOResources.
 *
 * @author N. Jourdane
 */
public abstract class VOResourceException extends Exception {

	/** An exception thrown when we can not get the VOResource, ie. an error in the query. */
	public static class CantGetVOResourceException extends VOResourceException {

		/** The serial version UID. */
		private static final long serialVersionUID = 1L;


		/**
		 * @param voResourceRequest The path of the VOResource.
		 * @param e The exception thrown.
		 */
		public CantGetVOResourceException(String voResourceRequest, Exception e) {
			super("Can not get the remote VOResource with the request: " + voResourceRequest, e);
		}
	}

	/** An exception thrown when we can not read the VOResource. */
	public static class CantReadVOResourceException extends VOResourceException {

		/** The serial version UID. */
		private static final long serialVersionUID = 1L;


		/**
		 * @param voResourcePath The path of the VOResource.
		 * @param e The exception thrown.
		 */
		public CantReadVOResourceException(String voResourcePath, Exception e) {
			super("Can not read the VOResource which should be stored in: " + voResourcePath, e);
		}
	}

	/**
	 * An exception thrown when the VOResource is not valid, ie. it don't have the expected body.
	 */
	public static class VOResourceIsNotValidException extends VOResourceException {

		/** The serial version UID. */
		private static final long serialVersionUID = 1L;


		/**
		 * @param voResourcePath The path of the VOResource.
		 * @param e The exception thrown.
		 */
		public VOResourceIsNotValidException(String voResourcePath, Exception e) {
			super("Can not parse the VOResource because it doesn't match with the VOResource schema."
					+ "\n See the VOResource file for more details: " + voResourcePath, e);
		}
	}


	/** The serial version UID. */
	private static final long serialVersionUID = 1L;


	/**
	 * @param message The message describing the exception displayed in the error dialog.
	 */
	public VOResourceException(String message) {
		super(message);
	}

	/**
	 * @param message The message describing the exception displayed in the error dialog.
	 * @param e The exception thrown.
	 */
	public VOResourceException(String message, Exception e) {
		super(message, e);
	}
}
