Skip to content

Commit 90a21a9

Browse files
committed
Tweak readme/examples
1 parent fcd8bad commit 90a21a9

File tree

2 files changed

+1
-19
lines changed

2 files changed

+1
-19
lines changed

README.md

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,6 @@ end
4444
stack_exchange = StackExchange.new("stackoverflow", 1)
4545
puts stack_exchange.questions
4646
puts stack_exchange.users
47-
48-
# Error Handling with :foul option
49-
# HTTParty provides a convenient way to handle common network errors using the :foul option
50-
begin
51-
HTTParty.get('https://api.example.com/users', foul: true)
52-
rescue HTTParty::Foul => e
53-
puts "Network error occurred: #{e.message}"
54-
puts "Original error: #{e.original_error.class}"
55-
end
56-
57-
# The :foul option wraps common network errors into HTTParty::Foul:
58-
# - Errno::ECONNREFUSED (Connection refused)
59-
# - Errno::ECONNRESET (Connection reset)
60-
# - Errno::EHOSTUNREACH (Host unreachable)
61-
# - EOFError (End of file error)
62-
# - Net::ReadTimeout (Read timeout)
63-
# - SocketError (DNS resolution errors)
64-
# - OpenSSL::SSL::SSLError (SSL certificate issues)
6547
```
6648

6749
See the [examples directory](http://github.com/jnunemaker/httparty/tree/main/examples) for even more goodies.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class APIClient
77
def self.fetch_user(id)
88
begin
99
get("/users/#{id}", foul: true)
10-
rescue HTTParty::Foul => e
10+
rescue HTTParty::NetworkError => e
1111
handle_network_error(e)
1212
rescue HTTParty::ResponseError => e
1313
handle_api_error(e)

0 commit comments

Comments
 (0)