Error.c 407 B

123456789101112131415161718192021
  1. #include <stdarg.h>
  2. #include <stdio.h>
  3. #include "Error.h"
  4. void eInitError(Error* e, int line, const char* format, ...) {
  5. e->line = line;
  6. va_list args;
  7. va_start(args, format);
  8. vsnprintf(e->message, sizeof(e->message), format, args);
  9. va_end(args);
  10. }
  11. void eInitSuccess(Error* e) {
  12. e->line = -1;
  13. e->message[0] = '\0';
  14. }
  15. bool eHasError(const Error* e) {
  16. return e->line >= 0;
  17. }