-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli): improve error message when encountering unsupported syntax
- Add NotFoundExportedKind error class - Add link for GitHub issue creation in CLI error message
- Loading branch information
Showing
8 changed files
with
175 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import type { IReason } from '#/compilers/interfaces/IReason'; | ||
import type * as tsm from 'ts-morph'; | ||
|
||
export class NotFoundExportedKind extends Error { | ||
#pos: { line: number; column: number }; | ||
|
||
#filePath: string; | ||
|
||
#node: tsm.Node; | ||
|
||
get pos() { | ||
return this.#pos; | ||
} | ||
|
||
get filePath() { | ||
return this.#filePath; | ||
} | ||
|
||
get node() { | ||
return this.#node; | ||
} | ||
|
||
constructor( | ||
pos: NotFoundExportedKind['pos'], | ||
filePath: string, | ||
node: tsm.Node, | ||
message?: string, | ||
) { | ||
super(message); | ||
|
||
this.#pos = pos; | ||
this.#node = node; | ||
this.#filePath = filePath; | ||
} | ||
|
||
get reason(): IReason { | ||
const message = | ||
`Cannot support export statement: (${this.#node.getKind()}) ${this.#node.getText()}`.trim(); | ||
|
||
return { | ||
type: 'error', | ||
lineAndCharacter: { | ||
line: this.#pos.line, | ||
character: this.#pos.column, | ||
}, | ||
nodes: this.#node == null ? undefined : [this.#node], | ||
filePath: this.#filePath, | ||
message, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters