[devdocsgjs/main: 593/1867] Better error handling and added a 15s timeout on HTTP requests
- From: Andy Holmes <andyholmes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [devdocsgjs/main: 593/1867] Better error handling and added a 15s timeout on HTTP requests
- Date: Fri, 19 Nov 2021 23:47:18 +0000 (UTC)
commit 11eeadbc0a7a6b098cdf04775e4738b01cbabba5
Author: Jasper van Merle <jaspervmerle gmail com>
Date: Sun Mar 10 23:15:40 2019 +0100
Better error handling and added a 15s timeout on HTTP requests
lib/docs/core/doc.rb | 7 ++++---
lib/tasks/updates.thor | 6 +++---
2 files changed, 7 insertions(+), 6 deletions(-)
---
diff --git a/lib/docs/core/doc.rb b/lib/docs/core/doc.rb
index 0b913ef6..4bdfcf15 100644
--- a/lib/docs/core/doc.rb
+++ b/lib/docs/core/doc.rb
@@ -223,13 +223,14 @@ module Docs
end
opts[:logger].debug("Fetching #{url}")
- response = Request.run(url, { headers: headers })
+ response = Request.run(url, { connecttimeout: 15, headers: headers })
if response.success?
response.body
else
- opts[:logger].error("Couldn't fetch #{url} (response code #{response.code})")
- nil
+ reason = response.timed_out? ? "Timed out while fetching #{url}" : "Couldn't fetch #{url} (response
code #{response.code})"
+ opts[:logger].error(reason)
+ raise reason
end
end
diff --git a/lib/tasks/updates.thor b/lib/tasks/updates.thor
index 66134581..20ef20b2 100644
--- a/lib/tasks/updates.thor
+++ b/lib/tasks/updates.thor
@@ -72,9 +72,9 @@ class UpdatesCLI < Thor
rescue NotImplementedError
logger.warn("Couldn't check #{doc.name}, get_latest_version is not implemented")
error_result(doc, '`get_latest_version` is not implemented')
- rescue
- logger.error("Error while checking #{doc.name}")
- raise
+ rescue => error
+ logger.error("Error while checking #{doc.name}\n#{error.full_message.strip}")
+ error_result(doc, error.message.gsub(/'/, '`'))
end
def format_version(version)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]