PythonMonkey   v0.9.1 (dev)
Loading...
Searching...
No Matches
setSpiderMonkeyException.cc File Reference

Call this function whenever a JS_* function call fails in order to set an appropriate python exception (remember to also return NULL) More...

#include "include/modules/pythonmonkey/pythonmonkey.hh"
#include "include/setSpiderMonkeyException.hh"
#include "include/StrType.hh"
#include "include/DictType.hh"
#include <jsapi.h>
#include <Python.h>
#include <codecvt>
#include <locale>
Include dependency graph for setSpiderMonkeyException.cc:

Functions

PyObject * getExceptionString (JSContext *cx, const JS::ExceptionStack &exceptionStack, bool printStack)
 Convert the given SpiderMonkey exception stack to a Python string.
 
void setSpiderMonkeyException (JSContext *cx)
 This function sets a python error under the assumption that a JS_* function call has failed. Do not call this function if that is not the case.
 

Detailed Description

Call this function whenever a JS_* function call fails in order to set an appropriate python exception (remember to also return NULL)

Author
Caleb Aikens (caleb.nosp@m.@dis.nosp@m.tribu.nosp@m.tive.nosp@m..netw.nosp@m.ork)
Date
2023-02-28

Function Documentation

◆ getExceptionString()

PyObject * getExceptionString ( JSContext *  cx,
const JS::ExceptionStack &  exceptionStack,
bool  printStack 
)

Convert the given SpiderMonkey exception stack to a Python string.

Parameters
cx- pointer to the JS context
exceptionStack- reference to the SpiderMonkey exception stack
printStack- whether or not to print the JS stack

the resulting python error string will be in the format: "Error in file <filename>, on line <lineno>: <offending line of code if relevant, nothing if not> <if offending line is present, then a '^' pointing to the relevant token> <spidermonkey error message> Stack Track: <stack trace>"

◆ setSpiderMonkeyException()

void setSpiderMonkeyException ( JSContext *  cx)

This function sets a python error under the assumption that a JS_* function call has failed. Do not call this function if that is not the case.

Parameters
cx- pointer to the JS context