FormatException
The .NET exception thrown when text cannot be parsed into the requested type, such as int.Parse("2O").
In more detail
Reading configuration as strings and parsing it at each call site produces this failure deep inside a request. The options pattern moves the conversion to startup.
Related terms
- exception — An error object a program raises to stop normal flow and report that something went wrong.
- options pattern — Binding a configuration section to a plain class with typed properties, validating it, and injecting it into services instead of reading raw strings.
Taught in
- The Options Pattern: Strongly Typed Configuration — Modern .NET Core, C# & Enterprise Microservices