-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from rinsed-org/better-error-handling
implement some better error handling
- Loading branch information
Showing
8 changed files
with
84 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
PATH | ||
remote: . | ||
specs: | ||
rb_snowflake_client (0.0.3) | ||
rb_snowflake_client (0.0.4) | ||
|
||
GEM | ||
remote: https://rubygems.org/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
module RubySnowflake | ||
class Client | ||
class HttpConnectionWrapper | ||
def initialize(hostname, port) | ||
@hostname = hostname | ||
@port = port | ||
end | ||
|
||
def start | ||
@connection = Net::HTTP.start(@hostname, @port, use_ssl: true) | ||
self | ||
rescue StandardError | ||
raise ConnectionError.new "Error connecting to server." | ||
end | ||
|
||
def request(request) | ||
# connections can timeout and close, re-open them | ||
# which is what the connection pool expects | ||
start unless connection.active? | ||
|
||
begin | ||
connection.request(request) | ||
rescue StandardError => error | ||
raise RequestError.new "HTTP error requesting data", cause: error | ||
end | ||
end | ||
|
||
private | ||
attr_accessor :connection | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters