Class jac::ExceptionWrapper
template <bool managed>
ClassList > jac > ExceptionWrapper
An exception wrapper which can either wrap a JSValue or contain an exception description and can be thrown into JS as a specific Error type. More...
#include <values.h>
Inherits the following classes: jac::ValueWrapper, std::exception
Public Types
| Type | Name |
|---|---|
| enum | Type |
Public Functions
| Type | Name |
|---|---|
| ExceptionWrapper (ValueWrapper< managed > value) Wrap an existing JSValue. If managed is true, JSValue will be freed when the Exception is destroyed. |
|
| ExceptionWrapper (ContextRef ctx, JSValue val) |
|
| std::string | stackTrace () noexcept Get the exception stack trace. |
| JSValue | throwJS (ContextRef ctx) Throw the exception into JS. |
| const char * | what () noexcept override const Get the exception message. |
Public Functions inherited from jac::ValueWrapper
| Type | Name |
|---|---|
| ValueWrapper (ContextRef ctx, JSValue val) Wrap an existing JSValue. If managed is true, JSValue will be freed when the Value is destroyed. |
|
| ValueWrapper (const ValueWrapper & other) |
|
| ValueWrapper (ValueWrapper && other) |
|
| JSValue & | getVal () Get reference to the underlying JSValue. |
| bool | isArray () Check if the Value is an array. |
| bool | isFunction () Check if the Value is a function. |
| bool | isNull () Check if the Value is null. |
| bool | isObject () Check if the Value is an object. |
| bool | isUndefined () Check if the Value is undefined. |
| std::pair< ContextRef, JSValue > | loot () Release ownership of the JSValue. The JSValue will have to be freed manually. |
| operator ValueWeak () |
|
| ValueWrapper & | operator= (const ValueWrapper & other) |
| ValueWrapper & | operator= (ValueWrapper && other) |
| Value | stringify (int indent=0) Convert the Value to a JSON representation. |
| T | to () Convert the Value to a specified type. |
| StringView | toString () Convert the Value to a StringView . |
| ~ValueWrapper () |
Public Static Functions
| Type | Name |
|---|---|
| Exception | create (Type type, std::string message) Create a new Exception. |
Public Static Functions inherited from jac::ValueWrapper
| Type | Name |
|---|---|
| Value | from (ContextRef ctx, T val) Create a new Value by converting a given value. |
| Value | fromJSON (ContextRef ctx, std::string json, std::string filename="<json>", bool extended=false) Create a new Value from a given JSON string. |
| Value | null (ContextRef ctx) Create a new Value containing null. |
| Value | undefined (ContextRef ctx) Create a new Value containing undefined. |
Protected Attributes inherited from jac::ValueWrapper
| Type | Name |
|---|---|
| ContextRef | _ctx |
| JSValue | _val |
Detailed Description
Template parameters:
managedwhether the JSValue should be freed when the wrapper is destroyed.
Public Types Documentation
enum Type
enum jac::ExceptionWrapper::Type {
Any,
Error,
SyntaxError,
TypeError,
ReferenceError,
RangeError,
InternalError
};
Public Functions Documentation
function ExceptionWrapper [2/3]
Wrap an existing JSValue. If managed is true, JSValue will be freed when the Exception is destroyed.
Note:
Used internally when directly working with QuickJS API. New Exception should be created using Exception::create() or by converting an existing Value to an Exception using Value::to<Exception>().
Parameters:
ctxcontext to work invalJSValue to wrap
function ExceptionWrapper [3/3]
function stackTrace
Get the exception stack trace.
Returns:
std::string containing the stack trace
function throwJS
Throw the exception into JS.
Note:
Used internally when directly working with QuickJS API. In most cases, exceptions should be thrown using a throw statement and wrapper functions will propagate the exception to JS.
Parameters:
ctxcontext to throw the exception in
Returns:
JSValue containing the exception
function what
Get the exception message.
Returns:
std::string containing the exception message
Public Static Functions Documentation
function create
Create a new Exception.
Parameters:
typetype of the exceptionmessageexception message
Returns:
The resulting Exception
The documentation for this class was generated from the following file src/jac/machine/values.h