<feed xmlns='http://www.w3.org/2005/Atom'>
<title>emacs-wttrin/tests/test-wttrin-geolocation--internals.el, branch main</title>
<subtitle>Emacs frontend for Igor Chubin's wttr.in weather service
</subtitle>
<id>https://git.cjennings.net/emacs-wttrin/atom?h=main</id>
<link rel='self' href='https://git.cjennings.net/emacs-wttrin/atom?h=main'/>
<link rel='alternate' type='text/html' href='https://git.cjennings.net/emacs-wttrin/'/>
<updated>2026-06-21T12:03:30+00:00</updated>
<entry>
<title>feat: add typed error hierarchy for fetch failures</title>
<updated>2026-06-21T12:03:30+00:00</updated>
<author>
<name>Craig Jennings</name>
<email>c@cjennings.net</email>
</author>
<published>2026-06-21T12:03:30+00:00</published>
<link rel='alternate' type='text/html' href='https://git.cjennings.net/emacs-wttrin/commit/?id=2f469404a4ef8bd0e8cdf776a5d25ba04b63febb'/>
<id>urn:sha1:2f469404a4ef8bd0e8cdf776a5d25ba04b63febb</id>
<content type='text'>
Define a wttrin-error condition with children wttrin-invalid-input, wttrin-network-error, wttrin-not-found-error, wttrin-service-error, and wttrin-parse-error, so callers branch on the class of a failure instead of matching message text.

Synchronous paths signal these directly: a nil query and an unknown geolocation provider now raise wttrin-invalid-input. The async fetch path can't signal across its callback, so it tags the error string with the class via a wttrin-error-type text property. The wttrin-error-message-type accessor reads it back, and two-arg callbacks are untouched.

Retyping the classifier also closed two gaps: a missing status and a 2xx with an empty body used to go silent or get mislabeled "Unexpected HTTP status". Both are now parse errors.

wttrin-geolocation.el now requires wttrin for the shared conditions. It's only ever loaded through wttrin, so the require is a no-op in practice and just makes the dependency explicit.
</content>
</entry>
<entry>
<title>test: cover wttrin-geolocation internal helpers</title>
<updated>2026-04-26T23:37:47+00:00</updated>
<author>
<name>Craig Jennings</name>
<email>c@cjennings.net</email>
</author>
<published>2026-04-26T23:37:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.cjennings.net/emacs-wttrin/commit/?id=439effb54aa8631751a758cb65140800af7e6e63'/>
<id>urn:sha1:439effb54aa8631751a758cb65140800af7e6e63</id>
<content type='text'>
Four pure helpers in wttrin-geolocation.el were exercised only indirectly through the parser tests: --decode-json, --format-city-region, --lookup-provider, and --extract-body. None of them had direct unit coverage. Edge cases like an empty JSON object, a missing-vs-empty city field, an unknown provider symbol, or a missing HTTP body separator weren't locked.

The new file groups all four functions together. Each gets Normal, Boundary, and Error cases per testing.md. Highlights:

- --decode-json: distinguishes nil input, empty string, and malformed JSON, all of which return nil for different reasons.
- --format-city-region: separates "missing key" from "empty string" since the predicate `(and (stringp city) (&gt; (length city) 0) ...)` short-circuits on either.
- --lookup-provider: tests two of the three built-ins plus a `let`-bound synthetic provider, locking the documented extension point on `wttrin-geolocation--providers`.
- --extract-body: real UTF-8 bytes inserted into a temp buffer (mirroring what `url-retrieve` delivers) verify the decoding path. 4xx, 5xx, and missing-separator paths each get their own test.

21 new tests, all green on first run since they characterize existing behavior.
</content>
</entry>
</feed>
