|
| 1 | +// Copyright 2021 the Polygon Mesh Processing Library developers. |
| 2 | +// Distributed under a MIT-style license, see LICENSE.txt for details. |
| 3 | + |
| 4 | +#pragma once |
| 5 | + |
| 6 | +#include <stdexcept> |
| 7 | + |
| 8 | +namespace pmp { |
| 9 | + |
| 10 | +//! \addtogroup core |
| 11 | +//! @{ |
| 12 | + |
| 13 | +//! \brief Exception indicating invalid input passed to a function. |
| 14 | +//! \details This exception should be used to signal violation of a |
| 15 | +//! precondition, e.g., if an algorithm expects a pure triangle mesh but a |
| 16 | +//! general polygon mesh is passed instead. |
| 17 | +class InvalidInputException : public std::invalid_argument |
| 18 | +{ |
| 19 | +public: |
| 20 | + InvalidInputException(const std::string& what) : std::invalid_argument(what) |
| 21 | + { |
| 22 | + } |
| 23 | +}; |
| 24 | + |
| 25 | +//! \brief Exception indicating failure so solve an equation system. |
| 26 | +class SolverException : public std::runtime_error |
| 27 | +{ |
| 28 | +public: |
| 29 | + SolverException(const std::string& what) : std::runtime_error(what) {} |
| 30 | +}; |
| 31 | + |
| 32 | +//! \brief Exception indicating failure to allocate a new resource. |
| 33 | +//! \details This exception signals an error resulting from an attempt to exceed |
| 34 | +//! implementation-defined allocation limits. |
| 35 | +class AllocationException : public std::length_error |
| 36 | +{ |
| 37 | +public: |
| 38 | + AllocationException(const std::string& what) : std::length_error(what) {} |
| 39 | +}; |
| 40 | + |
| 41 | +//! \brief Exception indicating a topological error has occurred. |
| 42 | +class TopologyException : public std::logic_error |
| 43 | +{ |
| 44 | +public: |
| 45 | + TopologyException(const std::string& what) : std::logic_error(what) {} |
| 46 | +}; |
| 47 | + |
| 48 | +//! \brief Exception indicating an error occurred while performing IO. |
| 49 | +class IOException : public std::runtime_error |
| 50 | +{ |
| 51 | +public: |
| 52 | + IOException(const std::string& what) : std::runtime_error(what) {} |
| 53 | +}; |
| 54 | + |
| 55 | +//! @} |
| 56 | + |
| 57 | +} // namespace pmp |
0 commit comments