Skip to content

Handle failed promises with better messaging - #43

Open
gmarcosb wants to merge 3 commits into
nknapp:masterfrom
gmarcosb:master
Open

Handle failed promises with better messaging#43
gmarcosb wants to merge 3 commits into
nknapp:masterfrom
gmarcosb:master

Conversation

@gmarcosb

Copy link
Copy Markdown

If a promise fails & returns a null value, fail with some additional info

Record args in case promise fails
Throw failure if promise failed
@nknapp

nknapp commented Oct 18, 2024

Copy link
Copy Markdown
Owner

Could you specify in more detail the input, the helpers and the expected result? That would help me understand what you want to do exactly.

You could also do this by adding a test case to your PR:

  • You probably need a helper that returns a rejecting promise here
  • And a new testcase here

@gmarcosb

gmarcosb commented Oct 18, 2024

Copy link
Copy Markdown
Author

So this is simply meant to be better logging

Effectively, today if a promise returns a null, the whole thing blows up without clear messaging about what failed ( replacePlaceholdersRecursivelyIn blows up with null inputs here)

This change makes it so that when a promise returns a null value, instead of blowing up in replacePlaceholdersRecursivelyIn with a null access, we blow up before with some information about the promise that returned a null value

In other words, it fails both before & after this change, but after this change it fails with a more helpful message vs no member toHtml on undefined

Additional test: I'm not too famliar with nodejs, mostly just hobbled this together by copy-pasting; there doesn't seem to be any tests for the failure cases, only the happy cases - shouldn't there already be some tests that cover this? 😅 Would happily modify it as that's more straightforward

Include function name for easier debugging
@gmarcosb

gmarcosb commented Dec 3, 2024

Copy link
Copy Markdown
Author

Gentle ping - reminder that this simply improves the error message from a null-access no member toHtml on undefined to more information about what led to the null value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants