mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 19:38:12 +00:00
LibWeb: Move DOMException from DOM/ to WebIDL/
This commit is contained in:
parent
ad04d7ac9b
commit
bbaa05fcf9
49 changed files with 206 additions and 203 deletions
|
@ -9,8 +9,8 @@
|
|||
#include <LibJS/Runtime/Promise.h>
|
||||
#include <LibWeb/Bindings/MainThreadVM.h>
|
||||
#include <LibWeb/Crypto/SubtleCrypto.h>
|
||||
#include <LibWeb/DOM/DOMException.h>
|
||||
#include <LibWeb/WebIDL/AbstractOperations.h>
|
||||
#include <LibWeb/WebIDL/DOMException.h>
|
||||
|
||||
namespace Web::Crypto {
|
||||
|
||||
|
@ -37,7 +37,7 @@ JS::Promise* SubtleCrypto::digest(String const& algorithm, JS::Handle<JS::Object
|
|||
// 2. Let data be the result of getting a copy of the bytes held by the data parameter passed to the digest() method.
|
||||
auto data_buffer_or_error = WebIDL::get_buffer_source_copy(*data.cell());
|
||||
if (data_buffer_or_error.is_error()) {
|
||||
auto error = DOM::OperationError::create(global_object(), "Failed to copy bytes from ArrayBuffer");
|
||||
auto error = WebIDL::OperationError::create(global_object(), "Failed to copy bytes from ArrayBuffer");
|
||||
auto* promise = JS::Promise::create(realm);
|
||||
promise->reject(error.ptr());
|
||||
return promise;
|
||||
|
@ -58,7 +58,7 @@ JS::Promise* SubtleCrypto::digest(String const& algorithm, JS::Handle<JS::Object
|
|||
}
|
||||
// 4. If an error occurred, return a Promise rejected with normalizedAlgorithm.
|
||||
else {
|
||||
auto error = DOM::NotSupportedError::create(global_object(), String::formatted("Invalid hash function '{}'", algorithm));
|
||||
auto error = WebIDL::NotSupportedError::create(global_object(), String::formatted("Invalid hash function '{}'", algorithm));
|
||||
auto* promise = JS::Promise::create(realm);
|
||||
promise->reject(error.ptr());
|
||||
return promise;
|
||||
|
@ -79,7 +79,7 @@ JS::Promise* SubtleCrypto::digest(String const& algorithm, JS::Handle<JS::Object
|
|||
auto digest = hash.digest();
|
||||
auto result_buffer = ByteBuffer::copy(digest.immutable_data(), hash.digest_size());
|
||||
if (result_buffer.is_error()) {
|
||||
auto error = DOM::OperationError::create(global_object(), "Failed to create result buffer");
|
||||
auto error = WebIDL::OperationError::create(global_object(), "Failed to create result buffer");
|
||||
promise->reject(error.ptr());
|
||||
return promise;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue