args-parser 6.3.6
Loading...
Searching...
No Matches
exceptions.hpp
Go to the documentation of this file.
1
2/*
3 SPDX-FileCopyrightText: 2026 Igor Mironchik <igor.mironchik@gmail.com>
4 SPDX-License-Identifier: MIT
5*/
6
7#ifndef ARGS__EXCEPTIONS_HPP__INCLUDED
8#define ARGS__EXCEPTIONS_HPP__INCLUDED
9
10// C++ include.
11#include <stdexcept>
12
13// Args include.
14#include "types.hpp"
15
16namespace Args
17{
18
19//
20// BaseException
21//
22
24class BaseException : public std::logic_error
25{
26public:
27 explicit BaseException(String what)
28 : std::logic_error("Please use desc() method of the exception.")
29 , m_what(std::move(what))
30 {
31 }
32
33 virtual ~BaseException() noexcept
34 {
35 }
36
38 const String &desc() const noexcept
39 {
40 return m_what;
41 }
42
43private:
45 String m_what;
46}; // class BaseException
47
48//
49// HelpHasBeenPrintedException
50//
51
54{
55public:
57 : BaseException(SL("Help has been printed."))
58 {
59 }
60}; // class HelpHasBeenPrintedException
61
62} /* namespace Args */
63
64#endif // ARGS__EXCEPTIONS_HPP__INCLUDED
virtual ~BaseException() noexcept
const String & desc() const noexcept
BaseException(String what)
Definition api.hpp:18
std::string String
String type.
Definition types.hpp:314
#define SL(str)
Definition types.hpp:328