mirror of
https://github.com/idris-lang/Idris2.git
synced 2025-01-08 08:52:22 +03:00
d910677d74
``` IDRIS2_VERIFY(cond, message_format, ...) ``` When condition is false, crash. Used in native functions where correct error handling is hard or not impossible. For example, `malloc` rarely fails, but if it fails, better crash with clear error message than spend time debugging null pointer dereference.
17 lines
397 B
C
17 lines
397 B
C
#include "idris_util.h"
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <stdarg.h>
|
|
|
|
void idris2_verify_failed(const char* file, int line, const char* cond, const char* fmt, ...) {
|
|
va_list ap;
|
|
va_start(ap, fmt);
|
|
|
|
char message[1000];
|
|
snprintf(message, sizeof(message), fmt, ap);
|
|
|
|
fprintf(stderr, "assertion failed in %s:%d: %s: %s\n", file, line, cond, message);
|
|
abort();
|
|
}
|