diff --git a/src/utils/functions/__tests__/get-first-return-value.js b/src/utils/functions/__tests__/get-first-return-value.js index 40050397..40e68bd5 100644 --- a/src/utils/functions/__tests__/get-first-return-value.js +++ b/src/utils/functions/__tests__/get-first-return-value.js @@ -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', () => { @@ -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'); + }); }); diff --git a/src/utils/packages/stylelint-resolver.js b/src/utils/packages/stylelint-resolver.js index d62c6101..7509d559 100644 --- a/src/utils/packages/stylelint-resolver.js +++ b/src/utils/packages/stylelint-resolver.js @@ -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;