GCC Code Coverage Report


Directory: ../
File: src/exception/CliError.cpp
Date: 2025-03-05 01:50:32
Exec Total Coverage
Lines: 0 22 0.0%
Functions: 0 3 0.0%
Branches: 0 33 0.0%

Line Branch Exec Source
1 // Copyright (c) 2021-2025 ChilliBits. All rights reserved.
2
3 #include "CliError.h"
4
5 #include <util/GlobalDefinitions.h>
6
7 namespace spice::compiler {
8
9 /**
10 * @param type Type of the error
11 * @param message Error message suffix
12 */
13 CliError::CliError(const CliErrorType &type, const std::string &message) {
14 errorMessage = "[Error|CLI] " + getMessagePrefix(type) + ": " + message;
15 }
16
17 /**
18 * Get the message for this particular error instance
19 *
20 * @return Error message in form of a char array
21 */
22 const char *CliError::what() const noexcept { return errorMessage.c_str(); }
23
24 /**
25 * Get the prefix of the error message for a particular error
26 *
27 * @param errorType Type of the error
28 * @return Prefix string for the error type
29 */
30 std::string CliError::getMessagePrefix(CliErrorType errorType) {
31 switch (errorType) {
32 case INCOMPLETE_TARGET_TRIPLE:
33 return "Incomplete target triple";
34 case INVALID_TARGET_TRIPLE:
35 return "Invalid target triple";
36 case SOURCE_FILE_MISSING:
37 return "Source file missing";
38 case OPT_DEBUG_INFO_INCOMPATIBILITY:
39 return "Cannot emit debug info with optimization enabled";
40 case NON_ZERO_EXIT_CODE:
41 return "Non-zero exit code";
42 case FEATURE_NOT_SUPPORTED_WHEN_DOCKERIZED:
43 return "Feature not supported when dockerized";
44 case INVALID_BUILD_MODE:
45 return "Invalid build mode";
46 case COMING_SOON_CLI:
47 return "Coming soon";
48 }
49 assert_fail("Unknown error"); // GCOV_EXCL_LINE
50 return "Unknown error"; // GCOV_EXCL_LINE
51 }
52
53 } // namespace spice::compiler
54