Skip to content

Commit

Permalink
Merge pull request #1795 from endojs/markm-omit-needless-stackframes
Browse files Browse the repository at this point in the history
refactor(patterns): Omit needless stackframes
  • Loading branch information
erights authored Sep 29, 2023
2 parents 52aba31 + 535d6b7 commit 1407148
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions packages/patterns/src/patterns/patternMatchers.js
Original file line number Diff line number Diff line change
Expand Up @@ -589,12 +589,23 @@ const makePatternKit = () => {
* @param {string|number} [label]
*/
const mustMatch = (specimen, patt, label = undefined) => {
if (checkMatches(specimen, patt, identChecker, label)) {
return;
let innerError;
try {
if (checkMatches(specimen, patt, identChecker, undefined)) {
return;
}
} catch (er) {
innerError = er;
}
// should only throw
checkMatches(specimen, patt, assertChecker, label);
Fail`internal: ${label}: inconsistent pattern match: ${q(patt)}`;
const outerError = assert.error(
X`internal: ${label}: inconsistent pattern match: ${q(patt)}`,
);
if (innerError !== undefined) {
assert.note(outerError, X`caused by ${innerError}`);
}
throw outerError;
};

// /////////////////////// getRankCover //////////////////////////////////////
Expand Down

0 comments on commit 1407148

Please sign in to comment.