/src/WasmEdge/include/po/error.h
Line | Count | Source (jump to first uncovered line) |
1 | | // SPDX-License-Identifier: Apache-2.0 |
2 | | // SPDX-FileCopyrightText: 2019-2024 Second State INC |
3 | | |
4 | | //===-- wasmedge/po/parser.h - Argument error -----------------------------===// |
5 | | // |
6 | | // Part of the WasmEdge Project. |
7 | | // |
8 | | //===----------------------------------------------------------------------===// |
9 | | #pragma once |
10 | | |
11 | | #include "experimental/expected.hpp" |
12 | | #include <string> |
13 | | #include <string_view> |
14 | | #include <utility> |
15 | | |
16 | | namespace WasmEdge { |
17 | | namespace PO { |
18 | | |
19 | | enum class ErrCode { |
20 | | InvalidArgument, |
21 | | OutOfRange, |
22 | | }; |
23 | | |
24 | | class Error { |
25 | | public: |
26 | 0 | Error(const Error &) = default; |
27 | | Error &operator=(const Error &) = default; |
28 | 0 | Error(Error &&) noexcept = default; |
29 | | Error &operator=(Error &&) noexcept = default; |
30 | | |
31 | 0 | Error(ErrCode C, std::string M) noexcept : Code(C), Message(std::move(M)) {} |
32 | 0 | ErrCode code() const noexcept { return Code; } |
33 | 0 | std::string_view message() const & noexcept { return Message; } |
34 | 0 | std::string message() && noexcept { return std::move(Message); } |
35 | | |
36 | | private: |
37 | | ErrCode Code; |
38 | | std::string Message; |
39 | | }; |
40 | | |
41 | | } // namespace PO |
42 | | } // namespace WasmEdge |