diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:35:49 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:35:49 +0000 |
commit | d8bbc7858622b6d9c278469aab701ca0b609cddf (patch) | |
tree | eff41dc61d9f714852212739e6b3738b82a2af87 /toolkit/components/uniffi-bindgen-gecko-js/src/templates/js | |
parent | Releasing progress-linux version 125.0.3-1~progress7.99u1. (diff) | |
download | firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.tar.xz firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.zip |
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/uniffi-bindgen-gecko-js/src/templates/js')
4 files changed, 14 insertions, 10 deletions
diff --git a/toolkit/components/uniffi-bindgen-gecko-js/src/templates/js/Enum.sys.mjs b/toolkit/components/uniffi-bindgen-gecko-js/src/templates/js/Enum.sys.mjs index f7716ac6d8..cbcc256eb9 100644 --- a/toolkit/components/uniffi-bindgen-gecko-js/src/templates/js/Enum.sys.mjs +++ b/toolkit/components/uniffi-bindgen-gecko-js/src/templates/js/Enum.sys.mjs @@ -16,7 +16,7 @@ export class {{ ffi_converter }} extends FfiConverterArrayBuffer { return {{ enum_.nm() }}.{{ variant.name().to_shouty_snake_case() }} {%- endfor %} default: - return new Error("Unknown {{ enum_.nm() }} variant"); + throw new UniFFITypeError("Unknown {{ enum_.nm() }} variant"); } } @@ -27,7 +27,7 @@ export class {{ ffi_converter }} extends FfiConverterArrayBuffer { return; } {%- endfor %} - return new Error("Unknown {{ enum_.nm() }} variant"); + throw new UniFFITypeError("Unknown {{ enum_.nm() }} variant"); } static computeSize(value) { @@ -72,7 +72,7 @@ export class {{ ffi_converter }} extends FfiConverterArrayBuffer { ); {%- endfor %} default: - return new Error("Unknown {{ enum_.nm() }} variant"); + throw new UniFFITypeError("Unknown {{ enum_.nm() }} variant"); } } @@ -86,7 +86,7 @@ export class {{ ffi_converter }} extends FfiConverterArrayBuffer { return; } {%- endfor %} - return new Error("Unknown {{ enum_.nm() }} variant"); + throw new UniFFITypeError("Unknown {{ enum_.nm() }} variant"); } static computeSize(value) { @@ -100,7 +100,7 @@ export class {{ ffi_converter }} extends FfiConverterArrayBuffer { return totalSize; } {%- endfor %} - return new Error("Unknown {{ enum_.nm() }} variant"); + throw new UniFFITypeError("Unknown {{ enum_.nm() }} variant"); } static checkType(value) { diff --git a/toolkit/components/uniffi-bindgen-gecko-js/src/templates/js/Error.sys.mjs b/toolkit/components/uniffi-bindgen-gecko-js/src/templates/js/Error.sys.mjs index b140d908da..c472f1a27d 100644 --- a/toolkit/components/uniffi-bindgen-gecko-js/src/templates/js/Error.sys.mjs +++ b/toolkit/components/uniffi-bindgen-gecko-js/src/templates/js/Error.sys.mjs @@ -46,7 +46,7 @@ export class {{ ffi_converter }} extends FfiConverterArrayBuffer { {%- endif %} {%- endfor %} default: - throw new Error("Unknown {{ error.nm() }} variant"); + throw new UniFFITypeError("Unknown {{ error.nm() }} variant"); } } static computeSize(value) { @@ -60,7 +60,7 @@ export class {{ ffi_converter }} extends FfiConverterArrayBuffer { return totalSize; } {%- endfor %} - throw new Error("Unknown {{ error.nm() }} variant"); + throw new UniFFITypeError("Unknown {{ error.nm() }} variant"); } static write(dataStream, value) { {%- for variant in error.variants() %} @@ -72,7 +72,7 @@ export class {{ ffi_converter }} extends FfiConverterArrayBuffer { return; } {%- endfor %} - throw new Error("Unknown {{ error.nm() }} variant"); + throw new UniFFITypeError("Unknown {{ error.nm() }} variant"); } static errorClass = {{ error.nm() }}; diff --git a/toolkit/components/uniffi-bindgen-gecko-js/src/templates/js/Object.sys.mjs b/toolkit/components/uniffi-bindgen-gecko-js/src/templates/js/Object.sys.mjs index e03291089e..204bf752dd 100644 --- a/toolkit/components/uniffi-bindgen-gecko-js/src/templates/js/Object.sys.mjs +++ b/toolkit/components/uniffi-bindgen-gecko-js/src/templates/js/Object.sys.mjs @@ -51,7 +51,11 @@ export class {{ ffi_converter }} extends FfiConverter { } static lower(value) { - return value[uniffiObjectPtr]; + const ptr = value[uniffiObjectPtr]; + if (!(ptr instanceof UniFFIPointer)) { + throw new UniFFITypeError("Object is not a '{{ object.nm() }}' instance"); + } + return ptr; } static read(dataStream) { diff --git a/toolkit/components/uniffi-bindgen-gecko-js/src/templates/js/Record.sys.mjs b/toolkit/components/uniffi-bindgen-gecko-js/src/templates/js/Record.sys.mjs index 2f54160b9e..638be5bee8 100644 --- a/toolkit/components/uniffi-bindgen-gecko-js/src/templates/js/Record.sys.mjs +++ b/toolkit/components/uniffi-bindgen-gecko-js/src/templates/js/Record.sys.mjs @@ -51,7 +51,7 @@ export class {{ ffi_converter }} extends FfiConverterArrayBuffer { static checkType(value) { super.checkType(value); if (!(value instanceof {{ record.nm() }})) { - throw new TypeError(`Expected '{{ record.nm() }}', found '${typeof value}'`); + throw new UniFFITypeError(`Expected '{{ record.nm() }}', found '${typeof value}'`); } {%- for field in record.fields() %} try { |