mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-21 02:32:06 +00:00
Refactor warnings and errors (#1728)
* Remove `err` and `warn`, keep `errx` and `warnx`, using them in RGBGFX too * Separate RGBGFX and RGBLINK warnings/errors from main options * Separate `report` function into `error` and `fatal` messages * Implicit newlines for most RGBASM errors
This commit is contained in:
@@ -65,7 +65,7 @@ Diagnostics<WarningLevel, WarningID> warnings = {
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
void printDiag(
|
||||
static void printDiag(
|
||||
char const *fmt, va_list args, char const *type, char const *flagfmt, char const *flag
|
||||
) {
|
||||
fputs(type, stderr);
|
||||
@@ -74,6 +74,7 @@ void printDiag(
|
||||
fprintf(stderr, flagfmt, flag);
|
||||
fputs("\n ", stderr);
|
||||
vfprintf(stderr, fmt, args);
|
||||
putc('\n', stderr);
|
||||
lexer_DumpStringExpansions();
|
||||
}
|
||||
|
||||
@@ -96,6 +97,28 @@ void error(char const *fmt, ...) {
|
||||
}
|
||||
}
|
||||
|
||||
void errorNoNewline(char const *fmt, ...) {
|
||||
va_list args;
|
||||
|
||||
fputs("error: ", stderr);
|
||||
fstk_DumpCurrent();
|
||||
fputs(":\n ", stderr);
|
||||
va_start(args, fmt);
|
||||
vfprintf(stderr, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
// This intentionally makes 0 act as "unlimited" (or at least "limited to sizeof(unsigned)")
|
||||
nbErrors++;
|
||||
if (nbErrors == maxErrors) {
|
||||
errx(
|
||||
"The maximum of %u error%s was reached (configure with \"-X/--max-errors\"); assembly "
|
||||
"aborted!",
|
||||
maxErrors,
|
||||
maxErrors == 1 ? "" : "s"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
[[noreturn]]
|
||||
void fatalerror(char const *fmt, ...) {
|
||||
va_list args;
|
||||
|
||||
Reference in New Issue
Block a user