Skip to content

Stop TimeZoneNotFoundException from being thrown every tick#141

Merged
danielchalmers merged 2 commits into
masterfrom
claude/elastic-murdock-fc807c
Jul 6, 2026
Merged

Stop TimeZoneNotFoundException from being thrown every tick#141
danielchalmers merged 2 commits into
masterfrom
claude/elastic-murdock-fc807c

Conversation

@danielchalmers

@danielchalmers danielchalmers commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Settings.TimeZoneInfo no longer relies on a caught TimeZoneNotFoundException as its normal fallback path:

  • An empty/whitespace TimeZone ID (the default) now returns TimeZoneInfo.Local directly without calling FindSystemTimeZoneById.
  • The resolved zone is cached against the ID that produced it, so a genuinely unknown ID throws once and reuses the fallback afterward. Changing the time zone (settings UI or an external settings-file edit) invalidates the cache since the stored ID no longer matches.
  • The fallback also covers InvalidTimeZoneException, which FindSystemTimeZoneById can throw for corrupt registry data.

TimeZone defaults to an empty string, so every read of Settings.Default.TimeZoneInfo threw and swallowed a TimeZoneNotFoundException. The main window caches its zone, but the format editor added in #140 refreshes its preview on a 1-second DispatcherTimer and reads the property each time — producing Exception thrown: 'System.TimeZoneNotFoundException' in mscorlib.dll in the debug output on every tick.

The TimeZoneInfo settings getter used a caught TimeZoneNotFoundException
as its fallback path, and the default TimeZone setting is an empty
string, so every read threw. The format editor preview reads it on a
one-second timer, spamming first-chance exceptions in the debugger.

Return Local directly for an empty ID, cache the resolved zone per ID
so an invalid ID throws once instead of every second, and also handle
InvalidTimeZoneException for corrupt registry data.
Signed-off-by: Daniel Chalmers <daniel.chalmers@outlook.com>
@danielchalmers danielchalmers added the bug Something isn't working label Jul 6, 2026
@danielchalmers danielchalmers merged commit ff6d3a8 into master Jul 6, 2026
4 checks passed
@danielchalmers danielchalmers deleted the claude/elastic-murdock-fc807c branch July 6, 2026 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant