Skip to content
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

💡 Dream API for error reporting (2022/7/28 draft) #10

Closed
favonia opened this issue Jul 28, 2022 · 2 comments · Fixed by #12
Closed

💡 Dream API for error reporting (2022/7/28 draft) #10

favonia opened this issue Jul 28, 2022 · 2 comments · Fixed by #12
Labels

Comments

@favonia
Copy link
Contributor

favonia commented Jul 28, 2022

Changes:

  • merge info and warning into print

Based on the Discord discussion:

E.tracef ?loc "when@ loading@ module@ %s" name @@ fun () -> ...
;;
E.printf ~code:`GalaxyNumber ?loc "number@ %i@ is@ too@ large" very_small_number
;;
E.fatalf ~code:`TypeError ?loc "%a@ does@ not@ have@ type@ %a" pp_tm tm pp_ty ty
;;
E.printf ~code:`EmojiError ?loc ~marks:all_occurrences
  "emoji@ %a@ is@ used@ more@ than@ %i@ times."
  pp_emoji emoji threshold
;;
E.messagef ~code:`TypeError ?loc
  "%s@ has@ type@ type@ %a,@ but@ we@ expected@ it@ to@ have@ type@ %a."
  var pp_tp actual pp_tp expected
|> E.mark [binding_loc1; binding_loc2]
|> E.fatal
;;
E.messagef ?loc ~code:`ChiError "variable@ name@ %s@ does@ not@ have@ any@ emojis." var
|> E.fatal ~marks:[]
;;
E.printf ?loc ~code:`ChiInfo "raise@ %s@ here." "CCHM"

In sum, we should have these functions

  1. (repeated) tracef to construct a backtrace
  2. messagef to construct a message
  3. mark to add, well, marks
  4. fatal(f) and print(f) to log something, and all four variants can take ?marks
  5. fatal(f) intends to end the program after printing out the message.
  6. The -f functions always take ?loc.
  7. No significance of the ordering of marks (via ?marks and/or calls of E.mark).
@favonia favonia changed the title 💡 Dream API (2022/7/28 draft) 💡 Dream API for error reporting (2022/7/28 draft) Jul 29, 2022
@favonia favonia linked a pull request Jul 30, 2022 that will close this issue
@favonia
Copy link
Contributor Author

favonia commented Jul 30, 2022

Further notes on location inheritance: no inheritance except for the LSP protocol.

@favonia
Copy link
Contributor Author

favonia commented Jul 30, 2022

Note: we need to decide what location (or none) to use when loc is omitted.

@TOTBWF TOTBWF closed this as completed in #12 Aug 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant