| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // Copyright (c) 2021-2025 ChilliBits. All rights reserved. | ||
| 2 | |||
| 3 | #pragma once | ||
| 4 | |||
| 5 | #include <cstdint> | ||
| 6 | #include <exception> | ||
| 7 | #include <string> | ||
| 8 | |||
| 9 | namespace spice::compiler { | ||
| 10 | |||
| 11 | // GCOV_EXCL_START | ||
| 12 | |||
| 13 | enum CliErrorType : uint8_t { | ||
| 14 | INCOMPLETE_TARGET_TRIPLE, | ||
| 15 | INVALID_TARGET_TRIPLE, | ||
| 16 | SOURCE_FILE_MISSING, | ||
| 17 | OPT_DEBUG_INFO_INCOMPATIBILITY, | ||
| 18 | NON_ZERO_EXIT_CODE, | ||
| 19 | FEATURE_NOT_SUPPORTED_WHEN_DOCKERIZED, | ||
| 20 | INVALID_BUILD_MODE, | ||
| 21 | COMING_SOON_CLI, | ||
| 22 | }; | ||
| 23 | |||
| 24 | /** | ||
| 25 | * Custom exception for errors, occurring when parsing the cli arguments | ||
| 26 | */ | ||
| 27 | class CliError final : public std::exception { | ||
| 28 | public: | ||
| 29 | // Constructors | ||
| 30 | CliError(const CliErrorType &type, const std::string &message); | ||
| 31 | |||
| 32 | // Public methods | ||
| 33 | [[nodiscard]] const char *what() const noexcept override; | ||
| 34 | |||
| 35 | private: | ||
| 36 | // Members | ||
| 37 | std::string errorMessage; | ||
| 38 | |||
| 39 | [[nodiscard]] static std::string getMessagePrefix(CliErrorType errorType); | ||
| 40 | }; | ||
| 41 | |||
| 42 | // GCOV_EXCL_STOP | ||
| 43 | |||
| 44 | } // namespace spice::compiler | ||
| 45 |