lib/backlog_kit/error.rb in backlog_kit-0.12.1 vs lib/backlog_kit/error.rb in backlog_kit-0.13.0
- old
+ new
@@ -1,6 +1,16 @@
module BacklogKit
+
+ # Custom error class for rescuing from Backlog errors
+ #
+ # @see http://developer.nulab-inc.com/docs/backlog/error-response
class Error < StandardError
+
+ # Make a custom error message
+ #
+ # @param response [Hash] Error response
+ # @param index [Integer] Index of the error
+ # @return [String] Error message
def self.build_error_message(response, index)
message = "[ERROR #{index}] "
message += "#{self.name.demodulize} - #{response['message']} (CODE: #{response['code']})"
more_info = response['moreInfo'].to_s
message += " (MORE INFO: #{more_info})" unless more_info.empty?