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

feat: log all resolution errors #302

Merged
merged 3 commits into from
Nov 3, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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');
});
});
6 changes: 4 additions & 2 deletions src/utils/packages/stylelint-resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,10 @@ class StylelintResolver {
stylelint,
resolvedPath: stylelintPath,
};
} catch {
// ignore
} catch (error) {
this.#logger?.debug('Failed to resolve Stylelint from global or workspace node_modules.', {
error,
});
}

return undefined;
Expand Down