GCC Code Coverage Report


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

Line Branch Exec Source
1 // Copyright (c) 2021-2025 ChilliBits. All rights reserved.
2
3 #include "LinkerError.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 LinkerError::LinkerError(const LinkerErrorType &type, const std::string &message) {
14 errorMessage = "[Error|Linker] " + 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 *LinkerError::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 LinkerError::getMessagePrefix(LinkerErrorType errorType) {
31 switch (errorType) {
32 case LINKER_NOT_FOUND:
33 return "Linker not found";
34 case LINKER_ERROR:
35 return "Linker error occurred";
36 }
37 assert_fail("Unknown error"); // GCOV_EXCL_LINE
38 return "Unknown error"; // GCOV_EXCL_LINE
39 }
40
41 } // namespace spice::compiler
42