Error
Python equivalents of JavaScript Error types.
jstypes.JSErrorData
jstypes.JSErrorData(self,
str | None = None,
message: *,
str = JSErrorName.Error,
name: str | None = None,
stack: object | None = None,
cause: )
A minimal representation of a JavaScript Error
.
This type holds just the JavaScript Error
fields that are stored in the V8 Serialization format. It doesn’t extend Python’s Exception type. Use this to represent JavaScript Error values that don’t need to be treated like Python Exceptions.
Parameters
Name | Type | Description | Default |
---|---|---|---|
message | str | None | A description of the error. | None |
name | str | The name of the error type. Can be anything, but values not in JSErrorName are equivalent to using "Error" . |
JSErrorName.Error |
stack | str | None | The stack trace detailing where the error happened. | None |
cause | object | None | Any object or value that caused this error. | None |
Methods
Name | Description |
---|---|
builder | Create a JSErrorData by copying another, satisfying JSErrorBuilder . |
from_exception | Create JSErrorData that reproduces the details of a Python Exception. |
from_traceback_exception | Create JSErrorData containing details from a TracebackException . |
builder
/) jstypes.JSErrorData.builder(initial_js_error: AnyJSError,
Create a JSErrorData
by copying another, satisfying JSErrorBuilder
.
This is a JSErrorBuilder
function to configure TagReader
to build JSErrorData
s.
from_exception
BaseException) jstypes.JSErrorData.from_exception(exc:
Create JSErrorData
that reproduces the details of a Python Exception.
from_traceback_exception
jstypes.JSErrorData.from_traceback_exception(tbe: TracebackException)
Create JSErrorData
containing details from a TracebackException
.
jstypes.JSError
jstypes.JSError(self,
str | None = None,
message: *,
str | JSErrorName = JSErrorName.Error,
name: str | None = None,
stack: object | None = None,
cause: )
A Python Exception that represents a JavaScript Error.
This is intended to be used to handle JavaScript errors on the Python side. To send Python errors to JavaScript, use JSErrorData.from_exception() to format a Python Exception like a JavaScript Error. (This happens automatically when serializing Python Exceptions.)
Attributes
Name | Description |
---|---|
cause | Another error (or arbitrary object) that this error was caused by. |
message | The JavaScript Error’s message. |
name | The JavaScript Error’s name. |
stack | The stack trace showing details of the Error and the calls that lead up |
Methods
Name | Description |
---|---|
builder | Create a JSError by copying another, satisfying JSErrorBuilder . |
from_js_error | Create a JSError by copying fields from another JSError-like object. |
builder
/) jstypes.JSError.builder(initial_js_error: AnyJSError,
Create a JSError
by copying another, satisfying JSErrorBuilder
.
This is a JSErrorBuilder
function to configure TagReader
to build JSError
s.
TagReader
has js_error_builder
option that this function can be passed to to have it create JSError
objects when deserializing JavaScript Errors.
from_js_error
jstypes.JSError.from_js_error(js_error: AnyJSError)
Create a JSError
by copying fields from another JSError-like object.