Rs
Module 6Robust ErrorsLesson 1 of 818 min

Error Handling Philosophy

When to Result, when to panic, how quant libs should fail.

Layers

  1. Pure math — Result for domain violations (vol <= 0, T < 0)
  1. Adapters — map parse/IO errors
  1. Edge — CLI/HTTP messages

Panic is for bugs

Bad CSV is Err. Broken internal invariant can panic.

Pricer policy

Invalid inputs → Err; never silent NaN.

Challenge

Replace String with enum VolError { NegativeStd, BadDays }.

Tips
  • Errors are values
  • Panic ≠ bad input
  • Document error cases

Try it live

Error Handling PhilosophyRust 2021
Loading editor…
Output
Press Run to compile and execute.