-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathExceptionType.hh
More file actions
43 lines (37 loc) · 1.22 KB
/
ExceptionType.hh
File metadata and controls
43 lines (37 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
* @file ExceptionType.hh
* @author Tom Tang (xmader@distributive.network) and Philippe Laporte (philippe@distributive.network)
* @brief Struct for representing Python Exception objects from a corresponding JS Error object
* @date 2023-04-11
*
* @copyright Copyright (c) 2023,2024 Distributive Corp.
*
*/
#ifndef PythonMonkey_ExceptionType_
#define PythonMonkey_ExceptionType_
#include <jsapi.h>
#include <Python.h>
/**
* @brief This struct represents a Python Exception object from the corresponding JS Error object
*/
struct ExceptionType {
public:
/**
* @brief Construct a new SpiderMonkeyError from the JS Error object.
*
* @param cx - javascript context pointer
* @param error - JS Error object to be converted
*
* @returns PyObject* pointer to the resulting PyObject
*/
static PyObject *getPyObject(JSContext *cx, JS::HandleObject error);
/**
* @brief Convert a python Exception object to a JS Error object
*
* @param cx - javascript context pointer
* @param exceptionValue - Exception object pointer, cannot be NULL
* @param traceBack - Exception traceback pointer, can be NULL
*/
static JSObject *toJsError(JSContext *cx, PyObject *exceptionValue, PyObject *traceBack);
};
#endif