Guidelines

Otto Allmendinger wrote:
> There are ~20 methods that crash when an input parameter is the empty string (search for `IsEmpty` in `OpenTransactions.cpp`, I think we should aggregate these methods in the linked ticket and fix it in one go.
>
> All other crashes should have separate ones.
>

An assert and a crash are two entirely different things.

An assert means, "Whatever just happened, should never happen, therefore
shut down the program immediately and produce a call stack, so as to
prevent any potential data corruptions and to find the cause as close as
possible to where it actually occurred."

For example, let's say there was a function like this:

   loadFile("test.txt");

The function has a single parameter, which should contain the filename.

Next, let's say there was some code like this:

int x(const char * pName)
{
  loadFile(pName);
}

But let's say pName is NULL (which should never happen.) I would expect
loadFile to contain an assert() on the name, to make sure it's not NULL.

Let's say the program asserts due to a NULL pName. This is due to a bug
in the code. Here's the fix:

int x(const char * pName)
{
   if (NULL == pName)
   {
      // log an error here and return.
   }

   loadFile(pName);
}

In the OT API, if you pass a NULL into a function that should NEVER
receive a NULL, that means there is a bug in your code.

Therefore, OT asserts immediately so you can catch the bug (with a call
stack) as close as possible to where the bug actually occurred.

If OT were to continue running without an assert, the actual cause of
the bug would be much harder to find, later on down the line. The point
of an assert is to catch the bug as close as possible to where it
actually occurred.