uuid: - value: 4c3faf72-fafe-4559-a496-7a0e1ddbc948 langcode: - value: en type: - target_id: daily_email target_type: node_type target_uuid: 8bde1f2f-eef9-4f2d-ae9c-96921f8193d7 revision_timestamp: - value: '2025-05-11T09:00:32+00:00' revision_uid: - target_type: user target_uuid: b8966985-d4b2-42a7-a319-2e94ccfbb849 revision_log: { } status: - value: true uid: - target_type: user target_uuid: b8966985-d4b2-42a7-a319-2e94ccfbb849 title: - value: | TDD and "Unexpected errors" created: - value: '2023-08-30T00:00:00+00:00' changed: - value: '2025-05-11T09:00:32+00:00' promote: - value: false sticky: - value: false default_langcode: - value: true revision_translation_affected: - value: true path: - alias: /daily/2023/08/30/tdd-and-unexpected-errors langcode: en body: - value: |

When working on projects, it's common to see messages like "The website encountered an unexpected error. Please try again later.".

Usually, this is the message shown to the user, whilst a more detailed error message is logged for Developers to diagnose and fix the underlying error.

The wording "unexpected error" has been intriguing to me, though. When do you expect an error?

The best example I can think of for an expected error is when doing test-driven development.

When doing TDD, you want to see an error to start as you start with a failing test.

Then, you write the code to remove the error and get the test passing.

format: full_html processed: |

When working on projects, it's common to see messages like "The website encountered an unexpected error. Please try again later.".

Usually, this is the message shown to the user, whilst a more detailed error message is logged for Developers to diagnose and fix the underlying error.

The wording "unexpected error" has been intriguing to me, though. When do you expect an error?

The best example I can think of for an expected error is when doing test-driven development.

When doing TDD, you want to see an error to start as you start with a failing test.

Then, you write the code to remove the error and get the test passing.

summary: null field_daily_email_cta: { }