[13f7525] | 1 | /*
|
---|
| 2 | * Copyright (c) 2018 Jaroslav Jindrak
|
---|
| 3 | * All rights reserved.
|
---|
| 4 | *
|
---|
| 5 | * Redistribution and use in source and binary forms, with or without
|
---|
| 6 | * modification, are permitted provided that the following conditions
|
---|
| 7 | * are met:
|
---|
| 8 | *
|
---|
| 9 | * - Redistributions of source code must retain the above copyright
|
---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
---|
| 11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 12 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 13 | * documentation and/or other materials provided with the distribution.
|
---|
| 14 | * - The name of the author may not be used to endorse or promote products
|
---|
| 15 | * derived from this software without specific prior written permission.
|
---|
| 16 | *
|
---|
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 27 | */
|
---|
| 28 |
|
---|
| 29 | #ifndef LIBCPP_STDEXCEPT
|
---|
| 30 | #define LIBCPP_STDEXCEPT
|
---|
| 31 |
|
---|
[0d221d2] | 32 | #include <exception>
|
---|
| 33 | #include <iosfwd>
|
---|
[7bbf91e] | 34 | #include <__bits/stringfwd.hpp>
|
---|
[0d221d2] | 35 |
|
---|
| 36 | namespace std
|
---|
| 37 | {
|
---|
| 38 | class logic_error: public exception
|
---|
| 39 | {
|
---|
| 40 | public:
|
---|
| 41 | explicit logic_error(const string&);
|
---|
| 42 | explicit logic_error(const char*);
|
---|
| 43 | logic_error(const logic_error&) noexcept;
|
---|
| 44 | logic_error& operator=(const logic_error&);
|
---|
| 45 | ~logic_error() override;
|
---|
| 46 |
|
---|
| 47 | const char* what() const noexcept override;
|
---|
| 48 |
|
---|
| 49 | protected:
|
---|
| 50 | const char* what_;
|
---|
| 51 | };
|
---|
| 52 |
|
---|
| 53 | class domain_error: public logic_error
|
---|
| 54 | {
|
---|
| 55 | public:
|
---|
| 56 | explicit domain_error(const string&);
|
---|
| 57 | explicit domain_error(const char*);
|
---|
| 58 | domain_error(const domain_error&) noexcept;
|
---|
| 59 | };
|
---|
| 60 |
|
---|
| 61 | class invalid_argument: public logic_error
|
---|
| 62 | {
|
---|
| 63 | public:
|
---|
| 64 | explicit invalid_argument(const string&);
|
---|
| 65 | explicit invalid_argument(const char*);
|
---|
| 66 | invalid_argument(const invalid_argument&) noexcept;
|
---|
| 67 | };
|
---|
| 68 |
|
---|
| 69 | class length_error: public logic_error
|
---|
| 70 | {
|
---|
| 71 | public:
|
---|
| 72 | explicit length_error(const string&);
|
---|
| 73 | explicit length_error(const char*);
|
---|
| 74 | length_error(const length_error&) noexcept;
|
---|
| 75 | };
|
---|
| 76 |
|
---|
| 77 | class out_of_range: public logic_error
|
---|
| 78 | {
|
---|
| 79 | public:
|
---|
| 80 | explicit out_of_range(const string&);
|
---|
| 81 | explicit out_of_range(const char*);
|
---|
| 82 | out_of_range(const out_of_range&) noexcept;
|
---|
| 83 | };
|
---|
| 84 |
|
---|
| 85 | class runtime_error: public exception
|
---|
| 86 | {
|
---|
| 87 | public:
|
---|
| 88 | explicit runtime_error(const string&);
|
---|
| 89 | explicit runtime_error(const char*);
|
---|
| 90 | runtime_error(const runtime_error&) noexcept;
|
---|
| 91 | runtime_error& operator=(const runtime_error&);
|
---|
| 92 | ~runtime_error() override;
|
---|
| 93 |
|
---|
| 94 | const char* what() const noexcept override;
|
---|
| 95 |
|
---|
| 96 | protected:
|
---|
| 97 | const char* what_;
|
---|
| 98 | };
|
---|
| 99 |
|
---|
| 100 | class range_error: public runtime_error
|
---|
| 101 | {
|
---|
| 102 | public:
|
---|
| 103 | explicit range_error(const string&);
|
---|
| 104 | explicit range_error(const char*);
|
---|
| 105 | range_error(const range_error&) noexcept;
|
---|
| 106 | };
|
---|
| 107 |
|
---|
| 108 | class overflow_error: public runtime_error
|
---|
| 109 | {
|
---|
| 110 | public:
|
---|
| 111 | explicit overflow_error(const string&);
|
---|
| 112 | explicit overflow_error(const char*);
|
---|
| 113 | overflow_error(const overflow_error&) noexcept;
|
---|
| 114 | };
|
---|
| 115 |
|
---|
| 116 | class underflow_error: public runtime_error
|
---|
| 117 | {
|
---|
| 118 | public:
|
---|
| 119 | explicit underflow_error(const string&);
|
---|
| 120 | explicit underflow_error(const char*);
|
---|
| 121 | underflow_error(const underflow_error&) noexcept;
|
---|
| 122 | };
|
---|
| 123 | }
|
---|
[13f7525] | 124 |
|
---|
| 125 | #endif
|
---|