GCC Code Coverage Report


Directory: ../
File: src/exception/LinkerError.cpp
Date: 2024-11-22 23:10:59
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-2024 ChilliBits. All rights reserved.
2
3 #include "LinkerError.h"
4
5 namespace spice::compiler {
6
7 /**
8 * @param type Type of the error
9 * @param message Error message suffix
10 */
11 LinkerError::LinkerError(const LinkerErrorType &type, const std::string &message) {
12 errorMessage = "[Error|Linker] " + getMessagePrefix(type) + ": " + message;
13 }
14
15 /**
16 * Get the message for this particular error instance
17 *
18 * @return Error message in form of a char array
19 */
20 const char *LinkerError::what() const noexcept { return errorMessage.c_str(); }
21
22 /**
23 * Get the prefix of the error message for a particular error
24 *
25 * @param errorType Type of the error
26 * @return Prefix string for the error type
27 */
28 std::string LinkerError::getMessagePrefix(LinkerErrorType errorType) {
29 switch (errorType) {
30 case LINKER_NOT_FOUND:
31 return "Linker not found";
32 case LINKER_ERROR:
33 return "Linker error occurred";
34 }
35 return "Unknown error"; // GCOV_EXCL_LINE
36 }
37
38 } // namespace spice::compiler
39