-
-
Notifications
You must be signed in to change notification settings - Fork 98
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
fix: capture ProcessException when hook generation fails due to dart pub get
#1242
Comments
dart pub get
Hi @alestiago 👋 mason/packages/mason/lib/src/hooks.dart Line 222 in 8bf695d
Can you share an example of what you'd expect the output to be? Thanks! |
Hi @felangel , this is quite old already and I don't have all the context I had back then. In a nutshell, the error was never a
I did notice the Consider: import 'dart:io';
Future<void> main() async {
final result = await Process.run('not-a-command', ['pub', 'get']);
if (result.exitCode != 0) {
throw Exception('Something went wrong!);
}
} Running the above throws "ProcessException: No such file or directory" not the exception. Whereas: import 'dart:io';
Future<void> main() async {
try {
await Process.run('not-a-command', ['pub', 'get']);
// ...
} catch (e) {
throw Exception('Something went wrong!');
}
} Does capture the
I would expect the output to be an error message with a verbose explanation that includes information about what the program was trying to do, and a recommendation to solve the failure. So for example, something along the lines: try {
await Process.run('not-a-command', ['pub', 'get']);
// ...
} catch (e) {
throw HookDependencyInstallFailure('''
Failed to install hook dependencies in $workingDirectory.
Make sure you have the Dart SDK installed and that the 'pub' command is available in your PATH.
''');
} |
Description
Running hooks using the Mason API throws a
ProcessException
if Dart executable is not installed.Steps To Reproduce
Expected Behavior
I would expect the error to be captured, it is currently not being captured.
I would expect a better error message that outlined the issue comes from Mason itself (since it is running the
dart pub get
internally) with a verbose description on how to resolve.Additional Context
dart pub get
is coming from Mason, see thatpreGen
calls_runHook
, that calls_installDependencies
that calls_dartPubGet
that callsdart pub get
.The text was updated successfully, but these errors were encountered: