Is it okay to use exceptions as tools to “catch” errors early?
I use exceptions to catch problems early. For example:
Is it okay to use exceptions as tools to “catch” errors early?
I use exceptions to catch problems early. For example:
MVC: Where is the right place to set error messages?
I have a ASP.NET MVC application where in all my Models have an Errors Property used to store non-validation errors which I than display in my Views. Where is the right place to populate the error list according to MVC? Inside the model or inside the controller?
MVC: Where is the right place to set error messages?
I have a ASP.NET MVC application where in all my Models have an Errors Property used to store non-validation errors which I than display in my Views. Where is the right place to populate the error list according to MVC? Inside the model or inside the controller?
MVC: Where is the right place to set error messages?
I have a ASP.NET MVC application where in all my Models have an Errors Property used to store non-validation errors which I than display in my Views. Where is the right place to populate the error list according to MVC? Inside the model or inside the controller?
Preferred way of handling errors when loading an object from a file
If I want to load an object from a file, there are a number of things that can go wrong. Thus, one needs a way of handling errors when doing so. In some languages, like haskell, one can return a Maybe
object that might contain the newly created object. In C++
, although it is in principle possible to create such a convenience class, it is usually not the most straight-forward way to do things. Below I list various ways errors could be handled when loading an object from a file in C++
.
Preferred way of handling errors when loading an object from a file
If I want to load an object from a file, there are a number of things that can go wrong. Thus, one needs a way of handling errors when doing so. In some languages, like haskell, one can return a Maybe
object that might contain the newly created object. In C++
, although it is in principle possible to create such a convenience class, it is usually not the most straight-forward way to do things. Below I list various ways errors could be handled when loading an object from a file in C++
.
How should I handle logger failures?
In several of our company’s applications, we use a custom logger. It’s fairly robust, though we may replace it with something like NLog in the future. One of the logger’s tasks is to log any exceptions encountered in the application.
How should I handle logger failures?
In several of our company’s applications, we use a custom logger. It’s fairly robust, though we may replace it with something like NLog in the future. One of the logger’s tasks is to log any exceptions encountered in the application.
Coerce bad input or always crash early
The general consensus seems to favor the Crash Early approach, the most reputable source being the acclaimed Pragmatic Programmer book.