-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
linker-error.spice
36 lines (32 loc) · 989 Bytes
/
linker-error.spice
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Own imports
import "../util/code-loc";
public type LinkerErrorType enum {
LINKER_NOT_FOUND,
LINKER_ERROR
}
/**
* Custom exception for errors, occurring when linking the output executable
*/
public type LinkerError struct {
string errorMessage
}
/**
* @param type Type of the error
* @param message Error message suffix
*/
public p LinkerError.ctor(const LinkerErrorType errorType, const string message) {
this.errorMessage = "[Error|Linker] " + this.getMessagePrefix(errorType) + ": " + message;
}
/**
* Get the prefix of the error message for a particular error
*
* @param errorType Type of the error
* @return Prefix string for the error type
*/
f<string> LinkerError.getMessagePrefix(const LinkerErrorType errorType) {
switch errorType {
case LinkerErrorType::LINKER_NOT_FOUND: { return "Linker not found"; }
case LinkerErrorType::LINKER_ERROR: { return "Linker error occurred"; }
default: { return "Unknown error"; }
}
}