Handle Faraday::ServerError (for example 502) as HTTPFailure

closes #8380
This commit is contained in:
Benjamin Neff 2022-07-24 00:22:43 +02:00
parent 78b28c3d54
commit 646685b42c
No known key found for this signature in database
GPG key ID: 971464C3F1A90194
3 changed files with 7 additions and 1 deletions

View file

@ -12,6 +12,7 @@
* Update the suggested Ruby version to 2.7. If you run into trouble during the update and you followed our installation guides, run `rvm install 2.7`. [#8366](https://github.com/diaspora/diaspora/pull/8366)
* Upgrade to bundler 2 [#8366](https://github.com/diaspora/diaspora/pull/8366)
* Stop checking `/.well-known/host-meta`, check for `/.well-known/nodeinfo` instead [#8377](https://github.com/diaspora/diaspora/pull/8377)
* Handle NodeInfo timeouts gracefully [#8380](https://github.com/diaspora/diaspora/pull/8380)
## Bug fixes
* Fix that no mails were sent after photo export [#8365](https://github.com/diaspora/diaspora/pull/8365)

View file

@ -109,7 +109,7 @@ class ConnectionTester
raise NetFailure, e.message
rescue Faraday::SSLError => e
raise SSLFailure, e.message
rescue ArgumentError, Faraday::ClientError => e
rescue ArgumentError, Faraday::ClientError, Faraday::ServerError => e
raise HTTPFailure, "#{e.class}: #{e.message}"
rescue StandardError => e
unexpected_error(e)

View file

@ -94,6 +94,11 @@ describe ConnectionTester do
expect { tester.request }.to raise_error(ConnectionTester::HTTPFailure)
end
it "receives a 502 bad gateway" do
stub_request(:get, url).to_return(status: 502, body: "Bad Gateway!")
expect { tester.request }.to raise_error(ConnectionTester::HTTPFailure)
end
it "cannot connect" do
stub_request(:get, url).to_raise(Faraday::ConnectionFailed.new("Error!"))
expect { tester.request }.to raise_error(ConnectionTester::NetFailure)