Skip to content

Commit

Permalink
feat: log all resolution errors (#302)
Browse files Browse the repository at this point in the history
* feat: log module resolution errors

* test: add failure case to getFirstReturnValue test
  • Loading branch information
adalinesimonian authored Nov 3, 2021
1 parent 65a6a06 commit c6f4078
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
16 changes: 16 additions & 0 deletions src/utils/functions/__tests__/get-first-return-value.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ describe('getFirstReturnValue', () => {
getFirstReturnValue(fn, fn, fn);
expect(fn).toHaveBeenCalledTimes(1);
});

test('if a function throws an error, it should be thrown', () => {
expect(() =>
getFirstReturnValue(() => {
throw new Error('foo');
}),
).toThrow('foo');
});
});

describe('getFirstResolvedValue', () => {
Expand Down Expand Up @@ -108,4 +116,12 @@ describe('getFirstResolvedValue', () => {
await getFirstResolvedValue(fn, fn, fn);
expect(fn).toHaveBeenCalledTimes(1);
});

test('if a function rejects, it should be rejected', async () => {
await expect(
getFirstResolvedValue(async () => {
throw new Error('foo');
}),
).rejects.toThrow('foo');
});
});
9 changes: 7 additions & 2 deletions src/utils/packages/stylelint-resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,13 @@ class StylelintResolver {
}

return result;
} catch {
// ignore
} catch (error) {
this.#logger?.debug(
'Failed to resolve Stylelint from workspace or globally-installed packages.',
{
error,
},
);
}

return undefined;
Expand Down

0 comments on commit c6f4078

Please sign in to comment.