GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/options/option_exception.h Lines: 7 7 100.0 %
Date: 2021-05-24 Branches: 2 4 50.0 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Morgan Deters, Aina Niemetz, Andres Noetzli
4
 *
5
 * This file is part of the cvc5 project.
6
 *
7
 * Copyright (c) 2009-2021 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.
11
 * ****************************************************************************
12
 *
13
 * Options-related exceptions.
14
 */
15
16
#include "cvc5_public.h"
17
18
#ifndef CVC5__OPTION_EXCEPTION_H
19
#define CVC5__OPTION_EXCEPTION_H
20
21
#include "base/exception.h"
22
#include "cvc5_export.h"
23
24
namespace cvc5 {
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
6
class CVC5_EXPORT OptionException : public cvc5::Exception
33
{
34
 public:
35
6
  OptionException(const std::string& s) : cvc5::Exception(s_errPrefix + s) {}
36
37
  /**
38
   * Get the error message without the prefix that is automatically added for
39
   * OptionExceptions.
40
   */
41
  std::string getRawMessage() const
42
  {
43
    return getMessage().substr(s_errPrefix.size());
44
  }
45
46
 private:
47
  /** The string to be added in front of the actual error message */
48
  static const std::string s_errPrefix;
49
}; /* class OptionException */
50
51
/**
52
 * Class representing an exception in option processing due to an
53
 * unrecognized or unsupported option key.
54
 */
55
2
class UnrecognizedOptionException : public cvc5::OptionException
56
{
57
 public:
58
  UnrecognizedOptionException()
59
      : cvc5::OptionException(
60
          "Unrecognized informational or option key or setting")
61
  {
62
  }
63
64
2
  UnrecognizedOptionException(const std::string& msg)
65
2
      : cvc5::OptionException(
66
2
          "Unrecognized informational or option key or setting: " + msg)
67
  {
68
2
  }
69
}; /* class UnrecognizedOptionException */
70
71
}  // namespace cvc5
72
73
#endif /* CVC5__OPTION_EXCEPTION_H */