GCC Code Coverage Report


Directory: ../
File: src/exception/CliError.cpp
Date: 2025-11-11 23:26:16
Coverage Exec Excl Total
Lines: 38.5% 10 1 27
Functions: 100.0% 3 0 3
Branches: 20.5% 8 0 39

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 2 CliError::CliError(const CliErrorType &type, const std::string &message) {
14
4/8
✓ Branch 4 → 5 taken 2 times.
✗ Branch 4 → 20 not taken.
✓ Branch 5 → 6 taken 2 times.
✗ Branch 5 → 18 not taken.
✓ Branch 6 → 7 taken 2 times.
✗ Branch 6 → 16 not taken.
✓ Branch 7 → 8 taken 2 times.
✗ Branch 7 → 14 not taken.
2 errorMessage = "[Error|CLI] " + getMessagePrefix(type) + ": " + message;
15 2 }
16
17 /**
18 * Get the message for this particular error instance
19 *
20 * @return Error message in form of a char array
21 */
22 2 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 2 std::string CliError::getMessagePrefix(CliErrorType errorType) {
31
2/11
✗ Branch 2 → 3 not taken.
✗ Branch 2 → 8 not taken.
✗ Branch 2 → 13 not taken.
✗ Branch 2 → 18 not taken.
✗ Branch 2 → 23 not taken.
✗ Branch 2 → 28 not taken.
✗ Branch 2 → 33 not taken.
✓ Branch 2 → 38 taken 1 time.
✓ Branch 2 → 43 taken 1 time.
✗ Branch 2 → 48 not taken.
✗ Branch 2 → 53 not taken.
2 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_FOR_TARGET:
43 return "Feature is not supported for this target";
44 case FEATURE_NOT_SUPPORTED_WHEN_DOCKERIZED:
45 return "Feature not supported when dockerized";
46 1 case INVALID_BUILD_MODE:
47
1/2
✓ Branch 40 → 41 taken 1 time.
✗ Branch 40 → 76 not taken.
2 return "Invalid build mode";
48 1 case INVALID_SANITIZER:
49
1/2
✓ Branch 45 → 46 taken 1 time.
✗ Branch 45 → 79 not taken.
2 return "Invalid sanitizer";
50 case COMING_SOON_CLI:
51 return "Coming soon";
52 }
53 assert_fail("Unknown error"); // GCOV_EXCL_LINE
54 return "Unknown error"; // GCOV_EXCL_LINE
55 }
56
57 } // namespace spice::compiler
58