/*
 * This file is part of the Owl Positioning System (OwlPS) project.
 * It is subject to the copyright notice and license terms in the
 * COPYRIGHT.t2t file found in the top-level directory of this
 * distribution and at
 *   https://code.lm7.fr/mcy/owlps/src/master/COPYRIGHT.t2t
 * No part of the OwlPS Project, including this file, may be copied,
 * modified, propagated, or distributed except according to the terms
 * contained in the COPYRIGHT.t2t file; the COPYRIGHT.t2t file must be
 * distributed along with this file, either separately or by replacing
 * this notice by the COPYRIGHT.t2t file's contents.
 */


#include "posexcept.hh"

#include <sstream>

using namespace std ;



/* *** Miscellaneous exceptions *** */


cannot_merge::
cannot_merge(const string &_explanation) throw():
  posexcept(_explanation) {}


element_already_exists::
element_already_exists(const string &_explanation) throw():
  posexcept("Element already exists in collection: " + _explanation) {}


element_not_found::
element_not_found(const string &_explanation) throw():
  posexcept("Element not found in collection: " + _explanation) {}


autocalibration_error::
autocalibration_error(const string &_explanation) throw():
  posexcept("Cannot generate reference points: " + _explanation) {}



/* *** Configuration *** */


missing_configuration::
missing_configuration(const string &_explanation) throw():
  posexcept(_explanation) {}


bad_configuration::
bad_configuration(const string &_explanation) throw():
  posexcept(_explanation) {}



/* *** Input *** */


malformed_input_data::
malformed_input_data(const string &_explanation) throw():
  posexcept("Read error: " + _explanation) {}


bad_direction::bad_direction(const char direction) throw()
{
  ostringstream message ;
  message << "`" << static_cast<int>(direction)
          << "` is not a valid direction value!" ;
  explanation = message.str() ;
}


bad_channel::bad_channel(const unsigned long channel) throw()
{
  ostringstream message ;
  message << "`" << channel
          << "` is not a valid channel value!" ;
  explanation = message.str() ;
}


null_input_medium::null_input_medium() throw():
  posexcept("The input medium is not initialised!") {}



/* *** Files *** */


error_opening_input_file::
error_opening_input_file(const string &file_name) throw():
  posexcept("Error opening input file \"" + file_name + "\"!") {}


error_opening_output_file::
error_opening_output_file(const string &file_name) throw():
  posexcept("Error opening output file \"" + file_name + "\"!") {}
