error.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #pragma once
  2. #include "pocketpy/common/str.h"
  3. #include "pocketpy/common/strname.h"
  4. #include "pocketpy/objects/sourcedata.h"
  5. #include "pocketpy/objects/object.h"
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. typedef struct pkpy_ExceptionFrame {
  10. pkpy_SourceData_ src;
  11. int lineno;
  12. const char* cursor;
  13. pkpy_Str name;
  14. } pkpy_ExceptionFrame;
  15. typedef struct pkpy_Exception {
  16. StrName type;
  17. pkpy_Str msg;
  18. bool is_re;
  19. int _ip_on_error;
  20. void* _code_on_error;
  21. PyObject* self; // weak reference
  22. c11_vector/*T=pkpy_ExceptionFrame*/ stacktrace;
  23. } pkpy_Exception;
  24. void pkpy_Exception__ctor(pkpy_Exception* self, StrName type);
  25. void pkpy_Exception__dtor(pkpy_Exception* self);
  26. void pkpy_Exception__stpush(pkpy_Exception* self, pkpy_SourceData_ src, int lineno, const char* cursor, const char* name);
  27. pkpy_Str pkpy_Exception__summary(pkpy_Exception* self);
  28. struct Error{
  29. const char* type;
  30. pkpy_SourceData_ src;
  31. int lineno;
  32. const char* cursor;
  33. char msg[100];
  34. int64_t userdata;
  35. };
  36. #ifdef __cplusplus
  37. }
  38. #endif