Commit 139e022
Detect YAML inputs by extension and report a missing file cleanly
Two defects in YAML handling:
- findYamls classified any token *containing* ".yaml"/".yml" as an input
file (substring match). An option value like -prefix=run.yaml.bak was
misclassified, then skipped from option parsing (line 122) and silently
dropped, and fed to YAML::LoadFile. Match a trailing extension instead.
- setOptionsValuesFromYamlFile caught only YAML::ParserException.
YAML::LoadFile throws YAML::BadFile (a sibling, both derive from
YAML::Exception) for a missing/unreadable path, so a mistyped *.yaml
filename escaped the catch and called std::terminate. Add a BadFile
catch with a clean "cannot open" message.
Verified: "gemc nonexistent.yaml" now prints "Cannot open yaml file ...
Check the path and spelling." and exits cleanly instead of terminating
with an uncaught exception (Geant4 11.4.1 dev container).
Fixes #125
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>1 parent 48f83e5 commit 139e022
1 file changed
Lines changed: 12 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
284 | 284 | | |
285 | 285 | | |
286 | 286 | | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
287 | 291 | | |
288 | 292 | | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
293 | 296 | | |
294 | 297 | | |
295 | 298 | | |
| |||
310 | 313 | | |
311 | 314 | | |
312 | 315 | | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
313 | 321 | | |
314 | 322 | | |
315 | 323 | | |
| |||
0 commit comments