mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:17:35 +00:00
LibJS+Everywhere: Convert JS::Error to String
This includes an Error::create overload to create an Error from a UTF-8 StringView. If creating a String from that view fails, the factory will return an OOM InternalError instead. VM::throw_completion can also make use of this overload via its perfect forwarding.
This commit is contained in:
parent
153b793638
commit
88814acbd3
36 changed files with 198 additions and 151 deletions
|
@ -100,7 +100,7 @@ public:
|
|||
// Keep this last:
|
||||
__Count,
|
||||
};
|
||||
DeprecatedString const& error_message(ErrorMessage) const;
|
||||
String const& error_message(ErrorMessage) const;
|
||||
|
||||
bool did_reach_stack_space_limit() const
|
||||
{
|
||||
|
@ -201,7 +201,12 @@ public:
|
|||
Completion throw_completion(Args&&... args)
|
||||
{
|
||||
auto& realm = *current_realm();
|
||||
return JS::throw_completion(T::create(realm, forward<Args>(args)...));
|
||||
auto completion = T::create(realm, forward<Args>(args)...);
|
||||
|
||||
if constexpr (IsSame<decltype(completion), ThrowCompletionOr<NonnullGCPtr<T>>>)
|
||||
return JS::throw_completion(MUST_OR_THROW_OOM(completion));
|
||||
else
|
||||
return JS::throw_completion(completion);
|
||||
}
|
||||
|
||||
template<typename T, typename... Args>
|
||||
|
@ -296,7 +301,7 @@ private:
|
|||
|
||||
PrimitiveString* m_empty_string { nullptr };
|
||||
PrimitiveString* m_single_ascii_character_strings[128] {};
|
||||
AK::Array<DeprecatedString, to_underlying(ErrorMessage::__Count)> m_error_messages;
|
||||
AK::Array<String, to_underlying(ErrorMessage::__Count)> m_error_messages;
|
||||
|
||||
struct StoredModule {
|
||||
ScriptOrModule referencing_script_or_module;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue