From 73c81a00a10766900318d86640249d1b54c6b351 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sat, 4 Apr 2026 16:32:16 -0500 Subject: feat: specific error messages for fetch failures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add HTTP status code checking (wttrin--extract-http-status) and pass error descriptions through the callback chain so users see "Location not found (HTTP 404)" or "Network error — check your connection" instead of the generic "Perhaps the location was misspelled?" for every failure. Also fix pre-existing bug where the condition-case error handler in extract-response-body killed an unrelated buffer after unwind-protect already cleaned up. 330 tests (was 307), all passing. --- tests/test-wttrin--fetch-url.el | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'tests/test-wttrin--fetch-url.el') diff --git a/tests/test-wttrin--fetch-url.el b/tests/test-wttrin--fetch-url.el index 9a2e58b..4bb02d7 100644 --- a/tests/test-wttrin--fetch-url.el +++ b/tests/test-wttrin--fetch-url.el @@ -41,7 +41,7 @@ (wttrin--fetch-url "http://example.com/weather" - (lambda (data) + (lambda (data &optional _error-msg) (setq callback-called t) (setq callback-data data))) @@ -61,7 +61,7 @@ (wttrin--fetch-url "http://example.com/weather" - (lambda (data) + (lambda (data &optional _error-msg) (setq callback-data data))) (should (string-match-p "☀️" callback-data)) @@ -82,7 +82,7 @@ (wttrin--fetch-url "http://example.com/weather" - (lambda (data) + (lambda (data &optional _error-msg) (setq callback-data data))) ;; Headers should not be in the data @@ -104,7 +104,7 @@ (wttrin--fetch-url "http://example.com/weather" - (lambda (data) + (lambda (data &optional _error-msg) (setq callback-data data))) (should (string= "" callback-data))))) @@ -122,7 +122,7 @@ (wttrin--fetch-url "http://example.com/weather" - (lambda (data) + (lambda (data &optional _error-msg) (setq callback-data data))) (should (= 10000 (length callback-data)))))) @@ -141,7 +141,7 @@ (wttrin--fetch-url "http://example.com/weather" - (lambda (data) + (lambda (data &optional _error-msg) (setq callback-data data))) (should (string= "Weather data" callback-data))))) @@ -160,7 +160,7 @@ (wttrin--fetch-url "http://example.com/weather" - (lambda (data) + (lambda (data &optional _error-msg) (setq callback-called t) (setq callback-data data))) @@ -180,7 +180,7 @@ (wttrin--fetch-url "http://example.com/weather" - (lambda (data) + (lambda (data &optional _error-msg) (setq callback-called t))) (should callback-called) -- cgit v1.2.3