-
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Description
Issue Description
Error messages lack sufficient context and debugging information. When errors occur, users see "Unknown error" but developers cannot easily determine what went wrong.
Risk Level
MEDIUM
Affected Files
src/scripts/index.js(Lines 38-58 indisplayError())
Details
Current Behavior
static displayError(msg) {
ArticleFiller.errMsg = msg?.trim();
if (ArticleFiller.errMsg?.length < 1) {
ArticleFiller.errMsg = "Unknown error"; // Not helpful
}
console.error(ArticleFiller.errMsg);
// ... displays error to user
}Problems
- "Unknown error" is not helpful for either users or developers
- Only the trimmed message is logged; error object details are lost
- No distinction between network errors, parsing errors, or fetch failures
- No context about what operation was being performed (fetch article, load carousel, etc.)
Expected Behavior
- Log full error object to console for developer debugging
- Display user-friendly message that explains what went wrong and suggests remediation
- Include operation context (which article, which page, etc.)
Example Improved Implementation
static displayError(msg, errorContext = {}) {
const errorObj = new Error(msg);
console.error('ArticleFiller Error:', {
message: msg,
context: errorContext,
stack: errorObj.stack,
timestamp: new Date().toISOString()
});
ArticleFiller.errMsg = msg?.trim() || "An unexpected error occurred. Please try refreshing the page.";
// ... display to user
}Solution Approach
- Enhance error logging with context information
- Improve user-facing error messages
- Add different error handlers for different failure types (network, parsing, missing data)
- Log to Sentry with appropriate error level and context
Labels
quality, error-handling, high
Reactions are currently unavailable