From 0dce5861f3e64f9ae1d389f3c30a401f5d9a878b Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Fri, 20 Mar 2020 09:45:12 -0700 Subject: [PATCH] Plugins/Wttr: return result as-is if JSON decode fails --- Plugins/Wttr.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Plugins/Wttr.pm b/Plugins/Wttr.pm index b5604f61..2164d471 100644 --- a/Plugins/Wttr.pm +++ b/Plugins/Wttr.pm @@ -123,7 +123,8 @@ sub get_wttr { if ($response->is_success) { $json = $response->decoded_content; } else { return "Failed to fetch weather data: " . $response->status_line; } - my $wttr = decode_json $json; + my $wttr = eval { decode_json $json }; + return $json if $@; # error decoding json so it must not be json -- return as-is if (exists $wttr->{nearest_area}) { my $areaName = $wttr->{nearest_area}->[0]->{areaName}->[0]->{value};