Skip to content

Commit

Permalink
fix: failOnError should destroy threadpool and exit with error code
Browse files Browse the repository at this point in the history
  • Loading branch information
adelsz committed Jan 29, 2023
1 parent 5f5803a commit aada874
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/cli/src/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ export async function queryToTypeDeclarations(
// tslint:disable:no-console
if (typeError) {
console.error('Error in query. Details: %o', typeData);
if (config.failOnError) {
throw new Error(
`Query "${queryName}" is invalid. Can't generate types.`,
);
}
} else {
console.error(
`Query '${queryName}' is invalid. Query contains an anonymous column. Consider giving the column an explicit name.`,
Expand Down
7 changes: 7 additions & 0 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ class FileProcessor {
}
} catch (err) {
if (err instanceof Error) {

const isWorkerTermination =
err.message === 'Terminating worker thread';
if (isWorkerTermination) {
return;
}

console.log(
`Error processing file: ${err.stack || JSON.stringify(err)}`,
);
Expand Down

1 comment on commit aada874

@vercel
Copy link

@vercel vercel bot commented on aada874 Jan 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

pgtyped – ./

pgtyped-git-master-adels.vercel.app
pgtyped.vercel.app
pgtyped-adels.vercel.app

Please sign in to comment.