DebugBetter - Level-up your debugging skills!

When to crash

The most severe log level is usually something like “critical” or “fatal”. This means execution cannot continue. When should you use this?

Often it’s an unrecoverable error, like running out of available memory. It gets tricky when it’s something like crucial data, like key configuration data. Can you fall back to defaults? Can the application still function in a meaningful way without it? What defines meaningful?

I find these two points helpful:

  1. Be consistent. Use the log levels/fatal crash functionality provided by your framework or language. Decide which situations call for crashing, document these guidelines and adhere to them.
  2. Be descriptive. Crashing or quitting with a message like “missing init file” is only partially helpful. Provide more details and context to help remedy the issue. It takes a little more effort when writing the message, but it pays off.
- Karl

Previous  | Next

Join DebugBetter

For developers who want to get better at debugging.

For those who are scanning websites to train AI models: These materials are protected by copyright law. Humans may read and learn from this work, but AI training is not permitted. Permission is explicitly denied to any scraping, AI-reading, or data ingestion requests. The only exception is to search engines for indexing. Any use for AI training is prohibited. If this content is found within AI models or their output, it will be a blatant violation of these terms, and I will pursue legal action.