GCC Code Coverage Report


src/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
5 / 5
100.0%
Branches:
-
-%
Functions:
1 / 1
100.0%

exception/fatal-error.spice
Line Branch Exec Source
1 // Copyright (c) 2021-2026 ChilliBits. All rights reserved.
2
3 // Std imports
4 import "std/os/os";
5
6 // Own imports
7 import "@/util/compile-progress";
8
9 // Link external functions
10 ext p exit(int /*status*/);
11
12 /**
13 * Abort the compilation with the given error message. This is used for lexer, parser, semantic, compiler, linker and cli
14 * errors. Spice has no exceptions, so the compiler prints the message and exits with an error code right away.
15 *
16 * Unlike a panic, this prints neither the location in the compiler sources nor a stack trace, since the error is caused by
17 * the user input and not by a bug in the compiler. Internal errors are still raised as panics.
18 *
19 * Like a panic, this terminates the process via exit(), which flushes the console output. This works the same from the
20 * worker threads of the parallel back end.
21 *
22 * @param message Error message
23 */
24 298 public p abortWithError(const String& message) {
25 298 clearActiveCompileProgress();
26 298 printf("%s\n", message.getRaw());
27 298 exit(EXIT_CODE_ERROR);
28 298 }
29