Richard Bucker

Fail Fast and Noisily, Fail Politely

Posted at — Jun 19, 2013

I believe that there is a deeper implication than documented in Joe Armstrongs PragProg book. To me it means that there is a perimeter of code that layers the inner function, behavior or action. This layer acts to validate incoming data per the requirements and handle the exceptions from the inner layer(s). All of which masks the intent that the closer to the center of the innermost layer the more reliable the task or operation is.


For example… 

This function does not require much error checking… or does it. The only bac thing that can happen might be an arithmetic overflow. But if the layer above restricted the range of numeric values then this would be perfectly fine.

add(A, B) -> A + B.

However, in this case the consequences are much more serious. In many systems and languages a divide by zero will cause a processor fault and that is a completely different error although it may bubble up the callstack in the same way that the previous arithmetic overflow does

divide(A, B) -> A / B.

In other examples…
  • When reading or writing from a file… everything from file integrity, lock escalation, file deleted while your operating on it…
  • Contacting a remote system and the timeout expires, the DNS fails to resolve or the shared secret is wrong…
  • Or when a complex set of codependent operations like a crypto function which depends on series of public and private keys to complete the operation; should any of the data malfunction…
In conclusion, “Fail Fast and Noisily, Fail Politely”, is an understatement. The authors should probably provide some proper idiomatic examples… Good Luck.