diff --git a/lib/getPostcssResult.js b/lib/getPostcssResult.js index 599fd2658c..45090ab344 100644 --- a/lib/getPostcssResult.js +++ b/lib/getPostcssResult.js @@ -93,10 +93,15 @@ function getCustomSyntax(customSyntax) { if (typeof customSyntax === 'string') { try { resolved = require(customSyntax); - } catch { - throw new Error( - `Cannot resolve custom syntax module "${customSyntax}". Check that module "${customSyntax}" is available and spelled correctly.`, - ); + } catch (error) { + // @ts-expect-error -- TS2571: Object is of type 'unknown'. + if (error && error.code === 'MODULE_NOT_FOUND') { + throw new Error( + `Cannot resolve custom syntax module "${customSyntax}". Check that module "${customSyntax}" is available and spelled correctly.`, + ); + } + + throw error; } /*