Thomas Mueller - 2026-10-09

Changing what an existing function does on failure is too dangerous: a caller that does not expect an exception would break, and the compiler cannot warn it. So the convention is:

  • New functions that can fail come in pairs: TryXxx returns a Boolean with an out parameter, Xxx raises.
  • An existing function that fails silently keeps doing so and gets a TryXxx next to it. Its doc comment says what it returns on failure.
  • An existing function that already raises stays as it is.
  • If an existing function is really wrong, the correct behaviour gets a new name and the old function is marked deprecated.

For the example in the description, this means adding TryGetModuleFilename, while GetModuleFilename keeps returning an empty string instead of raising EOSError.