From 274af988865accdae914e3645ea23bae8d8c425d Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 24 Feb 2021 22:05:43 +0100 Subject: global-functions: $GetMacVendor: improve error handling The API returns 404 on unknown mac vendor... We can just catch error, but not decide whether it is connection error or unknown vendor. Try without mac address - on error we have a connection issue. --- global-functions | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/global-functions b/global-functions index 79e0ea6..7425273 100644 --- a/global-functions +++ b/global-functions @@ -380,6 +380,13 @@ ("https://api.macvendors.com/" . [ :pick $Mac 0 8 ]) output=user as-value ]->"data"); :return $Vendor; } on-error={ + :do { + / tool fetch check-certificate=yes-without-crl ("https://api.macvendors.com/") \ + output=none as-value; + $LogPrintExit2 debug $0 ("The mac vendor is not known in database.") false; + } on-error={ + $LogPrintExit2 warning $0 ("Failed getting mac vendor.") false; + } :return "unknown vendor"; } } -- cgit v1.2.3-70-g09d2