error.cpp 680 B

12345678910111213141516171819202122232425262728293031
  1. /*
  2. * Copyright (c) 2012-2016 Daniele Bartolini and individual contributors.
  3. * License: https://github.com/taylor001/crown/blob/master/LICENSE
  4. */
  5. #include "error.h"
  6. #include "log.h"
  7. #include <stdarg.h>
  8. #include <stdlib.h> // exit
  9. namespace crown
  10. {
  11. namespace error
  12. {
  13. static void abort(const char* file, int line, const char* format, va_list args)
  14. {
  15. logev(format, args);
  16. loge("\tIn: %s:%d\n\nStacktrace:", file, line);
  17. print_callstack();
  18. exit(EXIT_FAILURE);
  19. }
  20. void abort(const char* file, int line, const char* format, ...)
  21. {
  22. va_list args;
  23. va_start(args, format);
  24. abort(file, line, format, args);
  25. va_end(args);
  26. }
  27. } // namespace error
  28. } // namespace crown