1 /*********************                                                        */
2 /*! \file option_exception.h
3  ** \verbatim
4  ** Top contributors (to current version):
5  **   Morgan Deters, Andres Noetzli, Tim King
6  ** This file is part of the CVC4 project.
7  ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS
8  ** in the top-level source directory) and their institutional affiliations.
9  ** All rights reserved.  See the file COPYING in the top-level source
10  ** directory for licensing information.\endverbatim
11  **
12  ** \brief Options-related exceptions
13  **
14  ** Options-related exceptions.
15  **/
16 
17 #include "cvc4_public.h"
18 
19 #ifndef __CVC4__OPTION_EXCEPTION_H
20 #define __CVC4__OPTION_EXCEPTION_H
21 
22 #include "base/exception.h"
23 
24 namespace CVC4 {
25 
26 /**
27  * Class representing an option-parsing exception such as badly-typed
28  * or missing arguments, arguments out of bounds, etc.  If an option
29  * name is itself unrecognized, a UnrecognizedOptionException (a derived
30  * class, below) should be used instead.
31  */
32 class CVC4_PUBLIC OptionException : public CVC4::Exception {
33  public:
OptionException(const std::string & s)34   OptionException(const std::string& s) : CVC4::Exception(s_errPrefix + s) {}
35 
36   /**
37    * Get the error message without the prefix that is automatically added for
38    * OptionExceptions.
39    */
getRawMessage()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 exception in option processing due to an
52  * unrecognized or unsupported option key.
53  */
54 class CVC4_PUBLIC UnrecognizedOptionException : public CVC4::OptionException {
55  public:
UnrecognizedOptionException()56   UnrecognizedOptionException() :
57     CVC4::OptionException("Unrecognized informational or option key or setting") {
58   }
59 
UnrecognizedOptionException(const std::string & msg)60   UnrecognizedOptionException(const std::string& msg) :
61     CVC4::OptionException("Unrecognized informational or option key or setting: " + msg) {
62   }
63 };/* class UnrecognizedOptionException */
64 
65 }/* CVC4 namespace */
66 
67 #endif /* __CVC4__OPTION_EXCEPTION_H */
68