#ifndef H_CORAL_EXCEPTION
#define H_CORAL_EXCEPTION
// This file is part of the Coral project.
// Please read the copyright notice in the LICENSE file.

#include <coral/coral.h>

#include <exception>
#include <string>
#include <stdexcept>

NAMESPACE_BEGIN(coral);

/**
 *
 * All coral-specific exceptions are gathered under
 * this superclass.
 * 
 * Note that other exceptions might also
 * be created, such as std::bad_alloc.
 *
 * Note that even though there are subsystem-specific
 * exceptions defined, not all exceptions thrown from it
 * are instances of the given function. Again, an example
 * is std::bad_alloc.
 */
class coral_error : public std::runtime_error {
public:
	coral_error(const std::string& what) : runtime_error(what) { ; }
};

/**
 * Thrown when a specific language is not found.
 */
class language_not_found_error : public coral_error {
public:
	language_not_found_error(const std::string& wwhat
				 = "<a language was not found error>")
		: coral_error(wwhat) { ; }
};

/**
 * Thrown when a non-existing slot of an element is accessed
 */
class bad_slot : public coral_error {
 public:
	bad_slot(const std::string& wwhat = "<unknown bad_slot error>")
		: coral_error(wwhat) { ; }
};

/**
 * Thrown when a file couldn't be loaded.
 */
class load_error : public coral_error {
 public:
	load_error(const std::string& wwhat = "<unknown load error>")
		: coral_error(wwhat) { ; }
};

/**
 * Thrown when a file couldn't be saved.
 */
class save_error : public coral_error {
 public:
	save_error(const std::string& wwhat = "<unknown save error>")
		: coral_error(wwhat) { ; }
};

NAMESPACE_END();

#endif
