LCOV - code coverage report
Current view: top level - buildbot/coverage/build/src/options - option_exception.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 6 6 100.0 %
Date: 2026-04-09 10:29:23 Functions: 2 2 100.0 %
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /******************************************************************************
       2                 :            :  * This file is part of the cvc5 project.
       3                 :            :  *
       4                 :            :  * Copyright (c) 2009-2026 by the authors listed in the file AUTHORS
       5                 :            :  * in the top-level source directory and their institutional affiliations.
       6                 :            :  * All rights reserved.  See the file COPYING in the top-level source
       7                 :            :  * directory for licensing information.
       8                 :            :  * ****************************************************************************
       9                 :            :  *
      10                 :            :  * Options-related exceptions.
      11                 :            :  */
      12                 :            : 
      13                 :            : #include "cvc5_public.h"
      14                 :            : 
      15                 :            : #ifndef CVC5__OPTION_EXCEPTION_H
      16                 :            : #define CVC5__OPTION_EXCEPTION_H
      17                 :            : 
      18                 :            : #include <cvc5/cvc5_export.h>
      19                 :            : 
      20                 :            : #include "base/exception.h"
      21                 :            : 
      22                 :            : namespace cvc5::internal {
      23                 :            : 
      24                 :            : /**
      25                 :            :  * Class representing an option-parsing exception such as badly-typed
      26                 :            :  * or missing arguments, arguments out of bounds, etc.
      27                 :            :  */
      28                 :            : class CVC5_EXPORT OptionException : public cvc5::internal::Exception
      29                 :            : {
      30                 :            :  public:
      31                 :      11256 :   OptionException(const std::string& s)
      32                 :      11256 :       : cvc5::internal::Exception(s_errPrefix + s)
      33                 :            :   {
      34                 :      11256 :   }
      35                 :            : 
      36                 :            :   /**
      37                 :            :    * Get the error message without the prefix that is automatically added for
      38                 :            :    * OptionExceptions.
      39                 :            :    */
      40                 :            :   std::string getRawMessage() const
      41                 :            :   {
      42                 :            :     return getMessage().substr(s_errPrefix.size());
      43                 :            :   }
      44                 :            : 
      45                 :            :  private:
      46                 :            :   /** The string to be added in front of the actual error message */
      47                 :            :   static const std::string s_errPrefix;
      48                 :            : }; /* class OptionException */
      49                 :            : 
      50                 :            : /**
      51                 :            :  * Class representing an option-parsing exception involving an illegal
      52                 :            :  * combination of options. In contrast to OptionException, it is treated as an
      53                 :            :  * unrecoverable exception in the API.
      54                 :            :  *
      55                 :            :  * At a high level, this exception is used when the user requests a illegal
      56                 :            :  * combination of options. It is *not* used in other cases, e.g., when the
      57                 :            :  * user requests an option that does not exist.
      58                 :            :  *
      59                 :            :  * In particular, we use this exception in two places:
      60                 :            :  * (1) If the SetDefaults detects an options misconfiguration, e.g., at the
      61                 :            :  *     beginning of a `check-sat` command, in which case any exception is
      62                 :            :  *     treated as unrecoverable.
      63                 :            :  * (2) If we discover an illegal combination of options during a `set-option`
      64                 :            :  *     command (e.g., due to restrictions on `safe-mode`).
      65                 :            :  *
      66                 :            :  * The latter is made a fatal exception for consistency, since some
      67                 :            :  * options misconfigurations are discovered during SetDefaults and others
      68                 :            :  * are detected eagerly. In either case we should abort.
      69                 :            :  */
      70                 :            : class CVC5_EXPORT FatalOptionException : public cvc5::internal::Exception
      71                 :            : {
      72                 :            :  public:
      73                 :          9 :   FatalOptionException(const std::string& s)
      74                 :          9 :       : cvc5::internal::Exception(s_errPrefix + s)
      75                 :            :   {
      76                 :          9 :   }
      77                 :            : 
      78                 :            :   /**
      79                 :            :    * Get the error message without the prefix that is automatically added for
      80                 :            :    * OptionExceptions.
      81                 :            :    * @return The raw error message.
      82                 :            :    */
      83                 :            :   std::string getRawMessage() const
      84                 :            :   {
      85                 :            :     return getMessage().substr(s_errPrefix.size());
      86                 :            :   }
      87                 :            : 
      88                 :            :  private:
      89                 :            :   /** The string to be added in front of the actual error message */
      90                 :            :   static const std::string s_errPrefix;
      91                 :            : }; /* class OptionException */
      92                 :            : 
      93                 :            : }  // namespace cvc5::internal
      94                 :            : 
      95                 :            : #endif /* CVC5__OPTION_EXCEPTION_H */

Generated by: LCOV version 1.14