From 6c6389e7f3e5d6b6a1191f73a80b1ffbc0795cc3 Mon Sep 17 00:00:00 2001 From: bptato Date: Wed, 8 Jan 2025 21:18:48 +0100 Subject: domexception: add legacy constant names --- src/html/domexception.nim | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'src/html') diff --git a/src/html/domexception.nim b/src/html/domexception.nim index d07e88f4..75787045 100644 --- a/src/html/domexception.nim +++ b/src/html/domexception.nim @@ -1,6 +1,8 @@ +import html/script import monoucha/javascript import monoucha/jserror import monoucha/quickjs +import monoucha/tojs import types/opt const NamesTable = { @@ -29,6 +31,33 @@ const NamesTable = { } type + DOMExceptionType = enum + INDEX_SIZE_ERR = 1 + DOMSTRING_SIZE_ERR = 2 + HIERARCHY_REQUEST_ERR = 3 + WRONG_DOCUMENT_ERR = 4 + INVALID_CHARACTER_ERR = 5 + NO_DATA_ALLOWED_ERR = 6 + NO_MODIFICATION_ALLOWED_ERR = 7 + NOT_FOUND_ERR = 8 + NOT_SUPPORTED_ERR = 9 + INUSE_ATTRIBUTE_ERR = 10 + INVALID_STATE_ERR = 11 + SYNTAX_ERR = 12 + INVALID_MODIFICATION_ERR = 13 + NAMESPACE_ERR = 14 + INVALID_ACCESS_ERR = 15 + VALIDATION_ERR = 16 + TYPE_MISMATCH_ERR = 17 + SECURITY_ERR = 18 + NETWORK_ERR = 19 + ABORT_ERR = 20 + URL_MISMATCH_ERR = 21 + QUOTA_EXCEEDED_ERR = 22 + TIMEOUT_ERR = 23 + INVALID_NODE_TYPE_ERR = 24 + DATA_CLONE_ERR = 25 + DOMException* = ref object of JSError name* {.jsget.}: string code {.jsget.}: uint16 @@ -52,4 +81,6 @@ func message0(this: DOMException): string {.jsfget: "message".} = return this.message proc addDOMExceptionModule*(ctx: JSContext) = - ctx.registerType(DOMException, JS_CLASS_ERROR, errid = opt(jeDOMException)) + let domExceptionCID = ctx.registerType(DOMException, JS_CLASS_ERROR, + errid = opt(jeDOMException)) + ctx.defineConsts(domExceptionCID, DOMExceptionType) -- cgit