error.cpp 583 B

12345678910111213141516171819202122232425262728
  1. /*
  2. * Copyright (c) 2012-2014 Daniele Bartolini and individual contributors.
  3. * License: https://github.com/taylor001/crown/blob/master/LICENSE
  4. */
  5. #include "error.h"
  6. #include "stacktrace.h"
  7. #include <stdlib.h>
  8. #include <stdio.h>
  9. #include <stdarg.h>
  10. namespace crown
  11. {
  12. namespace error
  13. {
  14. void abort(const char* file, int line, const char* message, ...)
  15. {
  16. va_list ap;
  17. va_start(ap, message);
  18. vprintf(message, ap);
  19. va_end(ap);
  20. printf("\tIn: %s:%d\n", file, line);
  21. printf("Stacktrace:\n");
  22. stacktrace();
  23. exit(EXIT_FAILURE);
  24. }
  25. } // namespace error
  26. } // namespace crown