-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/debug' into develop
- Loading branch information
Showing
7 changed files
with
68 additions
and
107 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
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,44 @@ | ||
class GenericSender | ||
|
||
# logs and puts the error according to its conditions and configuration | ||
# TODO refactor me! | ||
def self.communicate exception, response | ||
both, cmd, log = [], [], [] | ||
if exception.is_a?(GitReport::ServerError) | ||
@error_type = "server error" | ||
@details = JSON.parse(response.body)["message"] rescue response.body | ||
else | ||
@error_type = "client error" | ||
@details = exception.backtrace | ||
end | ||
both << "A #{@error_type} occured during data transfer." | ||
both << "Exception: #{exception}" | ||
if GitReport.global_opts[:trace] | ||
cmd << @details | ||
else | ||
cmd << "Run with --trace to get more info." | ||
end | ||
log << @details | ||
puts (both + cmd).join("\n") | ||
(both + log).each{ |line| grlog(0, "send_data! #{line}")} | ||
end | ||
|
||
# returns local storage | ||
def self.storage | ||
@@storage ||= GitReport::Storage.new(ENV['HOME'], '.gitreport_storage') | ||
end | ||
|
||
# returns configuration object | ||
def self.configuration | ||
@@configuration ||= GitReport.configuration | ||
end | ||
|
||
# returns the default headers | ||
def self.headers request | ||
request['User-Agent'] = 'gitreport-client-ruby' | ||
request['Content-Type'] = 'application/json' | ||
request['Accept'] = 'application/json' | ||
request['X-gitreport-Auth-Token'] = configuration.auth_token | ||
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