Skip to content

feat(weather): add error card and improve error handling#774

Merged
nicomiguelino merged 6 commits into
masterfrom
feat/weather-display-errors
May 27, 2026
Merged

feat(weather): add error card and improve error handling#774
nicomiguelino merged 6 commits into
masterfrom
feat/weather-display-errors

Conversation

@nicomiguelino
Copy link
Copy Markdown
Contributor

@nicomiguelino nicomiguelino commented Apr 6, 2026

User description

Summary

  • Add createErrorReporter that either throws (triggering panic-overlay when display_errors is enabled) or renders a custom error card in production
  • Add glassmorphic error card styled to match the forecast card, with landscape and portrait support
  • Throw on missing OpenWeatherMap API key instead of silently returning empty data
  • Wrap initialization in try/catch/finally with a single signalReady() call
  • Add no-api-key screenshot tests for 3840×2160 and 2160×3840
  • Update unit test to expect a thrown error when the API key is absent

PR Type

Enhancement, Bug fix, Tests, Documentation


Description

  • Adds configurable weather error handling

  • Shows missing-key error card

  • Tests no-key screenshots and throws

  • Documents display_errors app setting


Diagram Walkthrough

flowchart LR
  settings["display_errors setting"]
  init["weather initialization"]
  api["OpenWeatherMap API key check"]
  reporter["error reporter"]
  overlay["panic overlay"]
  card["in-app error card"]
  settings -- "controls" --> reporter
  init -- "validates" --> api
  api -- "failure" --> reporter
  reporter -- "debug enabled" --> overlay
  reporter -- "debug disabled" --> card
Loading

File Walkthrough

Relevant files
Tests
2 files
screenshots.spec.ts
Adds no-key screenshot coverage for error card                     
+41/-0   
weather.test.ts
Updates missing API key unit expectation                                 
+12/-10 
Error handling
1 files
main.ts
Adds configurable initialization error reporting                 
+49/-15 
Bug fix
1 files
weather.ts
Throws when forecast API key missing                                         
+8/-6     
Enhancement
2 files
style.css
Styles responsive glassmorphic error screen                           
+102/-0 
index.html
Adds hidden weather error screen markup                                   
+16/-0   
Documentation
1 files
README.md
Documents new `display_errors` setting                                     
+1/-0     
Configuration changes
2 files
screenly.yml
Adds `display_errors` manifest setting                                     
+12/-1   
screenly_qc.yml
Adds QC `display_errors` manifest setting                               
+12/-1   
Additional files
12 files
1080x1920.webp [link]   
1280x720.webp [link]   
1920x1080.webp [link]   
2160x3840.webp [link]   
2160x4096.webp [link]   
3840x2160.webp [link]   
4096x2160.webp [link]   
480x800.webp [link]   
720x1280.webp [link]   
800x480.webp [link]   
no-api-key-2160x3840.webp [link]   
no-api-key-3840x2160.webp [link]   

- Add display_errors setting to screenly.yml and screenly_qc.yml
- Call setupErrorHandling() in main.ts on DOMContentLoaded
- Add display_errors to e2e screenshot mock settings
- Document display_errors in README.md

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 6, 2026

PR Reviewer Guide 🔍

(Review updated until commit 74b0611)

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ No major issues detected

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 6, 2026

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Security
Honor error display setting

The documented display_errors setting is inverted here: when it is false, detailed
error messages are still shown on screen, and when it is true, the app throws
instead of using the new error card. Make the setting control whether detailed text
is displayed while still showing a safe error card to users.

edge-apps/weather/src/main.ts [32-39]

 function createErrorReporter(displayErrors: boolean): ErrorReporter {
-  if (displayErrors) {
-    return (msg) => {
-      throw new Error(msg)
-    }
+  return (msg) => {
+    showError(
+      displayErrors
+        ? msg
+        : 'The weather data could not be loaded. Please check your configuration or contact your administrator.',
+    )
   }
-  return showError
 }
Suggestion importance[1-10]: 8

__

Why: The suggestion correctly identifies that display_errors=false still displays detailed error messages via showError, while display_errors=true throws instead of using the app's error UI. The proposed change better matches the documented setting and avoids exposing detailed errors by default.

Medium

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a display_errors setting to the Weather edge app and wires in the shared setupErrorHandling() hook so runtime failures can be surfaced via the panic-overlay mechanism (plus updates docs and screenshot-test mocks).

Changes:

  • Added display_errors to screenly.yml and screenly_qc.yml (marked as optional + advanced).
  • Invoked setupErrorHandling() during app startup in src/main.ts.
  • Documented display_errors in the app README and included it in the e2e screenshot mock settings.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
edge-apps/weather/src/main.ts Calls shared error-handling setup on DOM ready.
edge-apps/weather/screenly.yml Adds display_errors manifest setting.
edge-apps/weather/screenly_qc.yml Adds display_errors manifest setting for QC.
edge-apps/weather/README.md Documents the new setting in the configuration table.
edge-apps/weather/e2e/screenshots.spec.ts Ensures screenshot mocks include display_errors.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread edge-apps/weather/src/main.ts
Comment thread edge-apps/weather/screenly.yml Outdated
Comment thread edge-apps/weather/screenly_qc.yml Outdated
@nicomiguelino nicomiguelino marked this pull request as ready for review April 6, 2026 23:08
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 6, 2026

Persistent review updated to latest commit 576e0ff

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 6, 2026

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Security
Honor error display setting

The documented display_errors setting is inverted here: when it is false, detailed
error messages are still shown on screen, and when it is true, the app throws
instead of using the new error card. Make the setting control whether detailed text
is displayed while still showing a safe error card to users.

edge-apps/weather/src/main.ts [32-39]

 function createErrorReporter(displayErrors: boolean): ErrorReporter {
-  if (displayErrors) {
-    return (msg) => {
-      throw new Error(msg)
-    }
+  return (msg) => {
+    showError(
+      displayErrors
+        ? msg
+        : 'The weather data could not be loaded. Please check your configuration or contact your administrator.',
+    )
   }
-  return showError
 }
Suggestion importance[1-10]: 8

__

Why: The suggestion correctly identifies that display_errors=false still displays detailed error messages via showError, while display_errors=true throws instead of using the app's error UI. The proposed change better matches the documented setting and avoids exposing detailed errors by default.

Medium

@nicomiguelino nicomiguelino marked this pull request as draft April 7, 2026 03:55
nicomiguelino and others added 4 commits April 6, 2026 21:27
- Use unindented list style for categories
- Move schema_version after properties in display_errors help_text

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Drop try/catch so unhandled errors propagate to panic-overlay
- Move signalReady() to end of happy path

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add `createErrorReporter` to toggle between panic overlay and error card based on `display_errors` setting
- Add glassmorphic error card (HTML + CSS) matching the forecast card style, with landscape and portrait support
- Throw on missing OpenWeatherMap API key instead of silently returning empty data
- Wrap initialization in try/catch/finally with a single `signalReady()$ call
- Add no-api-key screenshot tests for 3840x2160 and 2160x3840
- Update unit test to expect thrown error when API key is absent
@nicomiguelino nicomiguelino marked this pull request as ready for review May 27, 2026 16:50
@nicomiguelino nicomiguelino requested a review from Copilot May 27, 2026 16:50
@nicomiguelino nicomiguelino changed the title feat(weather): add display_errors setting feat(weather): add error card and improve error handling May 27, 2026
@github-actions
Copy link
Copy Markdown

Persistent review updated to latest commit 74b0611

@github-actions
Copy link
Copy Markdown

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Security
Honor error display setting

The documented display_errors setting is inverted here: when it is false, detailed
error messages are still shown on screen, and when it is true, the app throws
instead of using the new error card. Make the setting control whether detailed text
is displayed while still showing a safe error card to users.

edge-apps/weather/src/main.ts [32-39]

 function createErrorReporter(displayErrors: boolean): ErrorReporter {
-  if (displayErrors) {
-    return (msg) => {
-      throw new Error(msg)
-    }
+  return (msg) => {
+    showError(
+      displayErrors
+        ? msg
+        : 'The weather data could not be loaded. Please check your configuration or contact your administrator.',
+    )
   }
-  return showError
 }
Suggestion importance[1-10]: 8

__

Why: The suggestion correctly identifies that display_errors=false still displays detailed error messages via showError, while display_errors=true throws instead of using the app's error UI. The proposed change better matches the documented setting and avoids exposing detailed errors by default.

Medium

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 21 changed files in this pull request and generated 5 comments.

Comment thread edge-apps/weather/screenly.yml
Comment thread edge-apps/weather/screenly_qc.yml
Comment thread edge-apps/weather/src/main.ts
Comment thread edge-apps/weather/src/main.ts Outdated
Comment thread edge-apps/weather/src/weather.ts Outdated
…onstant

- Change `ErrorReporter` to accept `unknown` and rethrow the original error to preserve stack traces
- Extract duplicated API key error string into `MISSING_API_KEY_ERROR` constant in `weather.ts`
- Update `main.ts` and `weather.test.ts` to reference the shared constant
@nicomiguelino nicomiguelino merged commit 5f71975 into master May 27, 2026
4 checks passed
@nicomiguelino nicomiguelino deleted the feat/weather-display-errors branch May 27, 2026 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants