Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more user-friendly jsg exception message #2532

Merged
merged 1 commit into from
Aug 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/workerd/jsg/struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,9 @@ class StructWrapper<Self, T, TypeTuple<FieldWrappers...>, kj::_::Indexes<indices
kj::isSameType<typename FieldWrappers::Type, Unimplemented>()) && ...)) {
return T{};
}
jsg::throwTypeError(isolate, "Cannot initialize a dictionary with required members from an "
"undefined or null value.");
jsg::throwTypeError(isolate, kj::str("Cannot initialize ", typeid(T).name(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor nit but is this going to give a user friendly name that is useful for end users or something only we can appreciate?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Friendliness is debatable, but this is definitely something that will have a name similar to TS type.

" with required members from an "
"undefined or null value."));
}

if (!handle->IsObject()) return kj::none;
Expand Down
Loading