fix: capture ProcessException when hook generation fails due to `dart pub get`
- Dominant language
- Dart
- Stars
- 1.1k
- Forks
- 113
- PR merge metrics
- No merged PRs in 30d
Description
**Description**
Running hooks using the Mason API throws a `ProcessException` if Dart executable is not installed.
**Steps To Reproduce**
1. Run a Mason Generator:
```dart
final generator = await MasonGenerator.fromBundle(myBundle);
await generator.hooks.preGen(vars: {'name':'Dash'});
```
2. See error:
```txt
ProcessException: No such file or directory
Command: /bin/sh -c 'dart' 'pub' 'get'
```
**Expected Behavior**
I would expect the error to be captured, it is currently [not being captured](https://github.com/felangel/mason/blob/8bf695d1dee6ca3dc1a44241dcec00ee3603653d/packages/mason/lib/src/hooks.dart#L215).
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**
- The `dart pub get` is coming from Mason, see that [`preGen`](https://github.com/felangel/mason/blob/8bf695d1dee6ca3dc1a44241dcec00ee3603653d/packages/mason/lib/src/hooks.dart#L161) calls [`_runHook`](https://github.com/felangel/mason/blob/8bf695d1dee6ca3dc1a44241dcec00ee3603653d/packages/mason/lib/src/hooks.dart#L275), that calls [`_installDependencies`](https://github.com/felangel/mason/blob/8bf695d1dee6ca3dc1a44241dcec00ee3603653d/packages/mason/lib/src/hooks.dart#L229) that calls [`_dartPubGet`](https://github.com/felangel/mason/blob/8bf695d1dee6ca3dc1a44241dcec00ee3603653d/packages/mason/lib/src/hooks.dart#L214) that calls `dart pub get`.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.