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

Add missing assert.error method #554

Merged
merged 2 commits into from
Jan 1, 2021
Merged

Add missing assert.error method #554

merged 2 commits into from
Jan 1, 2021

Conversation

erights
Copy link
Contributor

@erights erights commented Jan 1, 2021

assert.error is an obviously missing method. Exactly like assert.fail for making an error with associated details. But unlike assert.fail it just returns the error rather than throwing it.

Currently the only way to get this effect from outside the assert module is

let err;
try {
  assert.fail(d`...`);
} catch (e) {
  err = e;
}

which would be just horrible.

Motivation:
While debugging a change to Agoric/agoric-sdk#1905 I'm seeing places where we're not logging info we should be due to the lack of this method.

@erights erights requested a review from kriskowal January 1, 2021 03:42
@erights erights self-assigned this Jan 1, 2021
@kriskowal
Copy link
Member

Maker names will be a tough sell if this goes up for standardization. assert.Error would be the easiest fit if it can be a constructor, assert.error is not so bad.

@erights
Copy link
Contributor Author

erights commented Jan 1, 2021

Maker names will be a tough sell if this goes up for standardization. assert.Error would be the easiest fit if it can be a constructor, assert.error is not so bad.

Done

@erights erights changed the title Add missing assert.makeError method Add missing assert.error method Jan 1, 2021
@erights erights merged commit c03b59d into master Jan 1, 2021
@erights erights deleted the assert_make_error branch January 1, 2021 06:28
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