Skip to content

Commit ed805d8

Browse files
committed
update error messages
1 parent 34714e6 commit ed805d8

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

src/context.js

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -84,24 +84,17 @@ export class Context {
8484
const visitor = this.#visitors[node.type];
8585

8686
if (!visitor) {
87-
let error = [`Failed to find an implementation for ${node.type}`];
87+
let message = `Not implemented: ${node.type}`;
8888

89-
if (node.type.includes('JSX')) {
90-
error.push(`hint: perhaps you need to use 'esrap/languages/jsx'`);
91-
}
9289
if (node.type.includes('TS')) {
93-
error.push(`hint: perhaps you need to use 'esrap/languages/ts'`);
94-
}
95-
if (node.type.includes('TSX')) {
96-
error.push(`hint: perhaps you need to use 'esrap/languages/tsx'`);
90+
message += ` (consider using 'esrap/languages/ts')`;
9791
}
98-
if (Object.keys(this.#visitors).length < 25) {
99-
error.push(
100-
`hint: perhaps you added custom visitors, but forgot to use 'esrap/languages/js'`
101-
);
92+
93+
if (node.type.includes('JSX')) {
94+
message += ` (consider using 'esrap/languages/tsx')`;
10295
}
10396

104-
throw new Error(error.join('\n'));
97+
throw new Error(message);
10598
}
10699

107100
if (this.#visitors._) {

0 commit comments

Comments
 (0)