Skip to content

Commit

Permalink
chore: print error messages instead of unreachable
Browse files Browse the repository at this point in the history
  • Loading branch information
acmepjz authored and hargoniX committed Jul 8, 2024
1 parent d1be57c commit 7a7a2ab
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions DocGen4/Output.lean
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,15 @@ def htmlOutputIndex (baseConfig : SiteBaseContext) : IO Unit := do
for entry in ← System.FilePath.readDir declarationsBasePath do
if entry.fileName.startsWith "declaration-data-" && entry.fileName.endsWith ".bmp" then
let fileContent ← FS.readFile entry.path
let .ok jsonContent := Json.parse fileContent | unreachable!
let .ok (module : JsonModule) := fromJson? jsonContent | unreachable!
index := index.addModule module |>.run baseConfig
match Json.parse fileContent with
| .error err =>
throw <| IO.userError s!"failed to parse file '{entry.path}' as json: {err}"
| .ok jsonContent =>
match fromJson? jsonContent with
| .error err =>
throw <| IO.userError s!"failed to parse file '{entry.path}': {err}"
| .ok (module : JsonModule) =>
index := index.addModule module |>.run baseConfig

let finalJson := toJson index
-- The root JSON for find
Expand Down

0 comments on commit 7a7a2ab

Please sign in to comment.