Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make SubprocessError as an error instance #82

Closed
LitoMore opened this issue Oct 26, 2024 · 2 comments · Fixed by #83
Closed

Make SubprocessError as an error instance #82

LitoMore opened this issue Oct 26, 2024 · 2 comments · Fixed by #83

Comments

@LitoMore
Copy link

LitoMore commented Oct 26, 2024

How about make the SubprocessError as an error instance instead of a type?

Currently it's a bit anonying when writing the error handling code in TypeScript:

try {
	await spawn(/* ... */);
} catch (error} {
	if (error instanceof Error && (error as SubprocessError).signalName === "SIGKILL") {
		// ...
	}
}

The code can be cleaner if we make the SubprocessError as an error instnace:

try {
	await spawn(/* ... */);
} catch (error} {
	if (error instanceof SubprocessError && error.signalName === "SIGKILL") {
		// ...
	}
}

Please correct me if there is a better way to write the code.

@ehmicky
Copy link
Collaborator

ehmicky commented Oct 27, 2024

Hi @LitoMore,

Thanks for the suggestion.
It makes sense. 👍

@ehmicky
Copy link
Collaborator

ehmicky commented Oct 27, 2024

Released with 0.2.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants