Commit ad6e6df
committed
bug #31 [Stimulus] Report a clear error for a missing or malformed controllers.json (Kocal)
This PR was merged into the main branch.
Discussion
----------
[Stimulus] Report a clear error for a missing or malformed controllers.json
| Q | A
| -------------- | ---
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Documentation? | no
| Issues | -
| License | MIT
When the `stimulus` option pointed at a `controllers.json` that was missing or contained invalid JSON, `generateControllersModule` threw a raw Node error (`ENOENT`, or a bare `SyntaxError`) instead of the clear ``@symfony`/reprise:`-prefixed message the rest of that module already uses for every other failure (package not installed, controller not declared, etc.).
This PR wraps the read and parse so a missing file and malformed JSON each produce an actionable ``@symfony`/reprise:` error naming the file, consistent with the module's other error paths.
Adds tests for both cases, plus a malformed JSON fixture. It's a pure core change, so it covers both bundlers through the shared `generateControllersModule`.
Commits
-------
8690952 [Stimulus] Report a clear error for a missing or malformed controllers.json3 files changed
Lines changed: 47 additions & 1 deletion
File tree
- assets
- src/core
- test
- core
- fixtures/stimulus
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
51 | 76 | | |
52 | 77 | | |
53 | 78 | | |
54 | 79 | | |
55 | 80 | | |
56 | | - | |
| 81 | + | |
57 | 82 | | |
58 | 83 | | |
59 | 84 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
41 | 61 | | |
42 | 62 | | |
43 | 63 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
0 commit comments