diff --git a/docs/sphinx_rsts/intro/exceptions_in_openfhe.rst b/docs/sphinx_rsts/intro/exceptions_in_openfhe.rst index cdc93738f..7eb08205a 100644 --- a/docs/sphinx_rsts/intro/exceptions_in_openfhe.rst +++ b/docs/sphinx_rsts/intro/exceptions_in_openfhe.rst @@ -1,45 +1,15 @@ Throwing Exceptions in OpenFHE =============================== -The OpenFHE library will throw a openfhe_error exception in the event of certain unrecoverable errors. A openfhe_error is a subclass of ``std::exception``. The library *actually* throws an exception which is a subclass of openfhe_error. +The OpenFHE library will throw an OpenFHEException exception in the event of an unrecoverable error. A openfhe_error is a subclass of ``std::exception``. -Programmers use the OPENFHE_THROW macro in exception.h to generate an exception. Each exception includes the filename and line number at which the exception was thrown as well as a programmer-defined message. +Programmers use the OPENFHE_THROW macro in exception.h to generate an exception. Each exception includes the filename, the function name and line number at which the exception was thrown as well as a programmer-defined message. -Exceptions and the methods associated with them are defined in ``src/core/include/utils/exception.h``. +OpenFHEException is defined in ``src/core/include/utils/exception.h``. -Available Exceptions ------------------------ - -The available exceptions are as follows - -config_error -^^^^^^^^^^^^^^^^ - -This exception is thrown whenever the user of the library supplies configuration parameters that cannot be used to configure OpenFHE. An example of this would be providing a ciphertext modulus that is not a prime number, or providing a plaintext modulus that cannot be used with a particular encoding type. - -math_error -^^^^^^^^^^^^^^^^ - -This exception is thrown whenever a math error occurs during the operation of the library. An example of this would be an overflow. - -serialization_error -^^^^^^^^^^^^^^^^^^^^ - -This exception is thrown whenever a fatal serialization error occurs. For example, if a required field is missing, this exception is thrown. - -not_implemented_error -^^^^^^^^^^^^^^^^^^^^^ - -This exception is thrown if a method is unimplemented. An example of this is a circumstance where a default implementation is provided in a base class, but an overridden exception is not provided in the derived class. - -not_available_error -^^^^^^^^^^^^^^^^^^^ - -This exception is thrown if a method is not available for a given configuration. For example, an arbitrary cyclotomics method is not available for a power-of-2 configuration. - Exceptions in critical regions and OMP threads ----------------------------------------------- diff --git a/src/core/include/utils/exception.h b/src/core/include/utils/exception.h index 3517d81ac..2455a47b2 100644 --- a/src/core/include/utils/exception.h +++ b/src/core/include/utils/exception.h @@ -100,7 +100,9 @@ class ThreadException { // }); // } // e.Rethrow(); -class openfhe_error : public std::runtime_error { + +class __attribute__((deprecated("OpenFHEException is the only exception class to be used in OpenFHE now."))) +openfhe_error : public std::runtime_error { std::string filename; int linenum; std::string message; @@ -123,40 +125,47 @@ class openfhe_error : public std::runtime_error { } }; -class config_error : public openfhe_error { +class __attribute__((deprecated("OpenFHEException is the only exception class to be used in OpenFHE now."))) +config_error : public openfhe_error { public: config_error(const std::string& file, int line, const std::string& what) : openfhe_error(file, line, what) {} }; -class math_error : public openfhe_error { +class __attribute__((deprecated("OpenFHEException is the only exception class to be used in OpenFHE now."))) math_error + : public openfhe_error { public: math_error(const std::string& file, int line, const std::string& what) : openfhe_error(file, line, what) {} }; -class not_implemented_error : public openfhe_error { +class __attribute__((deprecated("OpenFHEException is the only exception class to be used in OpenFHE now."))) +not_implemented_error : public openfhe_error { public: not_implemented_error(const std::string& file, int line, const std::string& what) : openfhe_error(file, line, what) {} }; -class not_available_error : public openfhe_error { +class __attribute__((deprecated("OpenFHEException is the only exception class to be used in OpenFHE now."))) +not_available_error : public openfhe_error { public: not_available_error(const std::string& file, int line, const std::string& what) : openfhe_error(file, line, what) {} }; -class type_error : public openfhe_error { +class __attribute__((deprecated("OpenFHEException is the only exception class to be used in OpenFHE now."))) type_error + : public openfhe_error { public: type_error(const std::string& file, int line, const std::string& what) : openfhe_error(file, line, what) {} }; // use this error when serializing openfhe objects -class serialize_error : public openfhe_error { +class __attribute__((deprecated("OpenFHEException is the only exception class to be used in OpenFHE now."))) +serialize_error : public openfhe_error { public: serialize_error(const std::string& file, int line, const std::string& what) : openfhe_error(file, line, what) {} }; // use this error when deserializing openfhe objects -class deserialize_error : public openfhe_error { +class __attribute__((deprecated("OpenFHEException is the only exception class to be used in OpenFHE now."))) +deserialize_error : public openfhe_error { public: deserialize_error(const std::string& file, int line, const std::string& what) : openfhe_error(file, line, what) {} }; diff --git a/src/pke/include/schemebase/base-fhe.h b/src/pke/include/schemebase/base-fhe.h index 761620bc1..252f71945 100644 --- a/src/pke/include/schemebase/base-fhe.h +++ b/src/pke/include/schemebase/base-fhe.h @@ -222,7 +222,7 @@ class FHEBase { */ virtual void EvalCompareSwitchPrecompute(const CryptoContextImpl& ccCKKS, uint32_t pLWE, double scaleSign, bool unit) { - OPENFHE_THROW(not_implemented_error, "EvalCompareSwitchPrecompute is not supported for this scheme"); + OPENFHE_THROW("EvalCompareSwitchPrecompute is not supported for this scheme"); } /**