/*
 * 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.votable.votable;

/**
 * VOTableException is the global exception for all the VOTable application. All other exceptions
 * should extend it.
 *
 * @author N. Jourdane
 */
public abstract class VOTableException extends Exception {

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


	/**
	 * Constructor of CantGetVOTableException with a message
	 *
	 * @param message The message describing the exception.
	 */
	public VOTableException(String message) {
		super(message);
	}

	/**
	 * Constructor of CantGetVOTableException with a message and the exception.
	 *
	 * @param message The message describing the exception.
	 * @param e The exception.
	 */
	public VOTableException(String message, Exception e) {
		super(message, e);
	}


	/** An exception thrown when we can not parse the VOTable data (ie. wrong column name). */
	public static class CanNotParseDataException extends VOTableException {

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


		/**
		 * @param reason A message explaining why we can't parse data.
		 */
		public CanNotParseDataException(String reason) {
			super("Can not parse data in the VOTable: " + reason);
		}

		/**
		 * @param reason A message explaining why we can't parse data.
		 * @param e The exception thrown.
		 */
		public CanNotParseDataException(String reason, Exception e) {
			super("Can not parse data in the VOTable: " + reason, e);
		}
	}

	/** An exception thrown when we can not get the VOTable, ie. an error in the query. */
	public static class CantAlterVOTableException extends VOTableException {

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


		/**
		 * @param reason A message explaining why we can't alter the VOTable.
		 * @param e The exception thrown.
		 */
		public CantAlterVOTableException(String reason, Exception e) {
			super("Can not alter the XML file of the VOTable: " + reason, e);
		}
	}

	/** An exception thrown when we can not get the VOTable, ie. an error in the query. */
	public static class CantDisplayVOTableException extends VOTableException {

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


		/**
		 * @param reason A message explaining why we can't display the VOTable.
		 */
		public CantDisplayVOTableException(String reason) {
			super("Can not display the VOTable: " + reason);
		}
	}

	/** An exception thrown when we can not get the VOTable, ie. an error in the query. */
	public static class CantGetVOTableException extends VOTableException {

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


		/**
		 * @param reason A message explaining why we can't get the VOTable.
		 */
		public CantGetVOTableException(String reason) {
			super("Can not get the VOTable: " + reason);
		}

		/**
		 * @param reason A message explaining why we can't get the VOTable.
		 * @param e The exception thrown.
		 */
		public CantGetVOTableException(String reason, Exception e) {
			super("Can not get the VOTable: " + reason, e);
		}
	}

	/** An exception thrown when we can not read the VOTable. */
	public static class CantParseVOTableException extends VOTableException {

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


		/**
		 * @param reason A message explaining why we can't get the VOTable.
		 * @param e The exception thrown.
		 */
		public CantParseVOTableException(String reason, Exception e) {
			super("Can not read the VOTable: " + reason, e);
		}
	}

	/** An exception thrown when we can not get the VOTable, ie. an error in the query. */
	public static class CantSaveVOTableException extends VOTableException {

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


		/**
		 * @param reason A message explaining why we can't get the VOTable.
		 * @param e The exception thrown.
		 */
		public CantSaveVOTableException(String reason, Exception e) {
			super("Can not save the VOTable: " + reason, e);
		}
	}

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

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


		/**
		 * @param reason A message explaining why we can't get the VOTable.
		 */
		public VOTableIsNotValidException(String reason) {
			super("The VOTable is not valid: " + reason);
		}
	}
}