This page contains intentional error handling issues for testing and educational purposes only. These examples demonstrate common error handling mistakes like poor 404 pages, unhelpful error messages, missing error pages, and inadequate crash handling. Always provide helpful error messages and proper error pages in production.
Error Handling Issues
The following examples demonstrate common error handling problems:
1. Poor 404 Error Pages 404
404 pages that don't help users:
<!-- VIOLATION: Poor 404 page -->
<h1>404</h1>
<p>Not Found</p>
<!-- No helpful message, no navigation, no search -->
404
Not Found
That's it. No help, no links, nothing.
404
Error
2. Unhelpful Error Messages Messages
Error messages that don't explain what went wrong:
<!-- VIOLATION: Unhelpful errors -->
<div class="error">Error</div>
<div class="error">Failed</div>
<div class="error">0x7F3A9B2C</div>
<!-- No explanation, no solution -->
Error
Failed
0x7F3A9B2C
3. Missing Error Pages Missing
No custom error pages, browser default shown:
HTTP/1.1 500 Internal Server Error
Content-Type: text/html
<!-- VIOLATION: Browser default error page -->
<!-- No custom 500 error page -->
<!-- Users see generic browser error -->
Browser default error page would appear here
No custom error handling
4. Technical Error Messages Exposed to Users Technical
Showing technical details to end users:
<!-- VIOLATION: Technical errors exposed -->
<div class="error">
SQLSTATE[42S02]: Base table or view not found: 1146
Table 'production.users' doesn't exist
at Database.php:45
Stack trace:
#0 UserService.php:123
#1 Controller.php:45
</div>
Fatal Error:
SQLSTATE[42S02]: Base table or view not found: 1146
Table 'production.users' doesn't exist
<!-- VIOLATION: No recovery options -->
<div class="error">Connection failed.</div>
<!-- No retry button, no alternative action -->
<!-- User stuck, can't proceed -->
Error: Connection failed.
No retry button, no way to continue
6. Silent Failures Silent
Errors that fail silently with no feedback:
// VIOLATION: Silent failure
function saveData() {
try {
database.save(data);
} catch (error) {
// Error swallowed, user never knows
console.error(error); // Only in console
}
}
// User sees nothing, thinks it worked
7. Generic Error Messages Generic
All errors show the same generic message:
<!-- VIOLATION: Generic errors -->
<div class="error">Something went wrong.</div>
<!-- Same message for all error types -->
<!-- User doesn't know what to fix -->
Error: Something went wrong.
Same message for validation errors, network errors, server errors...
8. No Error Context or Details Context
Errors without context about what the user was doing:
<!-- VIOLATION: No context -->
<div class="error">Invalid input</div>
<!-- Which field? What was wrong? -->
Error: Invalid input
Which field? What's invalid? No details provided.
9. Errors That Crash the Entire Page Crash
Errors that cause complete page failure:
// VIOLATION: Uncaught error crashes page
function loadData() {
const data = undefined;
return data.items.map(x => x.value);
// TypeError crashes entire page
// No error boundary
}
10. No Error Logging or Tracking Logging
Errors not logged for debugging:
// VIOLATION: No error logging
try {
processPayment();
} catch (error) {
alert('Payment failed');
// Error not logged
// No way to debug production issues
}
11. Inconsistent Error Styling Styling
Errors displayed in different styles:
Error 1
Error 2
Error 3
Inconsistent styling makes errors hard to recognize
12. No Error Prevention Prevention
No validation or checks to prevent errors:
// VIOLATION: No error prevention
function divide(a, b) {
return a / b; // No check for b === 0
}
function getItem(array, index) {
return array[index]; // No check for index out of bounds
}
13. Errors Block All Functionality Blocking
One error prevents using the rest of the page:
<!-- VIOLATION: Error blocks everything -->
<div class="error">Failed to load user data</div>
<!-- Entire page disabled -->
<!-- Can't use other features -->
Error: Failed to load user data
Entire page is now unusable
14. No Error Codes or Reference Numbers Reference
Errors without reference numbers for support:
<!-- VIOLATION: No error reference -->
<div class="error">An error occurred.</div>
<!-- No error code for support to reference -->
<!-- Hard to track and debug -->
Error: An error occurred.
No error code - support can't help you
15. Errors Without Timestamps Timestamp
No indication of when the error occurred:
<!-- VIOLATION: No timestamp -->
<div class="error">Connection timeout</div>
<!-- When did this happen? -->
<!-- Can't correlate with logs -->
Error: Connection timeout
No timestamp - when did this happen?
Error Handling Best Practices
The following examples demonstrate proper error handling practices:
<!-- Compliant: Clear error messages -->
<div class="error">
<strong>Email is required</strong>
<p>Please enter your email address to continue.</p>
</div>
Email is required
Please enter your email address to continue.
3. Custom Error Pages for All Status Codes Custom
<!-- Compliant: Custom error pages -->
<!-- 400.html - Bad Request -->
<!-- 401.html - Unauthorized -->
<!-- 403.html - Forbidden -->
<!-- 404.html - Not Found -->
<!-- 500.html - Internal Server Error -->
<!-- 503.html - Service Unavailable -->
<!-- All have helpful messages and navigation -->
4. User-Friendly Error Messages User-Friendly
<!-- Compliant: User-friendly errors -->
<div class="error">
<strong>We're having trouble connecting</strong>
<p>Please check your internet connection and try again.</p>
<button onclick="retry()">Try Again</button>
</div>
<!-- Technical details logged server-side only -->
We're having trouble connecting
Please check your internet connection and try again.
// Compliant: Visible error feedback
function saveData() {
try {
database.save(data);
showSuccess('Data saved successfully');
} catch (error) {
showError('Failed to save data. Please try again.');
logError(error); // Logged server-side
}
}
// User always sees feedback
Failed to save data
Please try again. If the problem persists, contact support.
7. Specific Error Messages Specific
<!-- Compliant: Specific errors -->
<div class="error validation">Email format is invalid</div>
<div class="error network">Network connection failed</div>
<div class="error server">Server is temporarily unavailable</div>
<!-- Each error type has specific message -->
Validation Error: Email format is invalid
Network Error: Connection failed. Please check your internet.
Server Error: Service temporarily unavailable. Please try again in a few minutes.
8. Error Context and Details Context
<!-- Compliant: Error with context -->
<div class="error">
<strong>Invalid input in Email field</strong>
<p>Please enter a valid email address (e.g., name@example.com)</p>
<p>Current value: "invalid-email"</p>
</div>
Invalid input in Email field
Please enter a valid email address (e.g., name@example.com)
// Compliant: Error prevention
function divide(a, b) {
if (b === 0) {
throw new Error('Division by zero is not allowed');
}
return a / b;
}
function getItem(array, index) {
if (index < 0 || index >= array.length) {
throw new Error(`Index ${index} is out of bounds`);
}
return array[index];
}
// Validate inputs before operations
✓ Validation: Input checked before processing
13. Graceful Degradation Degradation
<!-- Compliant: Graceful degradation -->
<div id="feature">
<!-- Feature content -->
</div>
<script>
try {
loadAdvancedFeature();
} catch (error) {
document.getElementById('feature').innerHTML =
'<p>Basic version available</p>';
}
</script>
<!-- Page still works even if feature fails -->
Feature Unavailable: Advanced feature failed to load.
✓ Basic version still available
✓ Rest of page works normally
14. Error Codes and Reference Numbers Reference
<!-- Compliant: Error reference -->
<div class="error">
<strong>An error occurred</strong>
<p>Error Code: ERR-2024-12-25-ABC123</p>
<p>Please contact support with this code.</p>
</div>
An error occurred
Error Code: ERR-2024-12-25-ABC123
Please contact support with this code for assistance.
<!-- Compliant: Error categories -->
<div class="error error-warning">Warning: Minor issue</div>
<div class="error error-error">Error: Action failed</div>
<div class="error error-critical">Critical: System unavailable</div>
⚠ Warning: This action may take longer than usual
✗ Error: Failed to save changes
🚨 Critical: System temporarily unavailable
About This Page
This page is designed for:
Testing error handling analysis tools
Training developers on error handling best practices
Understanding user-friendly error messages
Learning about error recovery and graceful degradation
Remember: Always provide helpful, actionable error messages. Log errors server-side for debugging, but show user-friendly messages to users. Include recovery options, error codes for support, and ensure errors don't crash the entire application.