Sha256: bc9986100ac4dbed0d2018e8ffe059ca9b9cca9b15670031b8a79ad7ea648cb6
Contents?: true
Size: 782 Bytes
Versions: 12
Compression:
Stored size: 782 Bytes
Contents
require 'travis/client' module Travis module Client class Error < StandardError end class NotFound < Error end class NotLoggedIn < Error end class ValidationFailed < Error attr_reader :errors def initialize(message = nil, *args) message = parse_message(message) if message super(message, *args) end def parse_message(message) response = JSON.load(message) message = response['message'].to_s if @errors = response['errors'] and @errors.any? readable = @errors.map { |e| "#{e['field']}: #{e['code'].gsub('_', ' ')}" } message += " (#{readable.join(', ')})" end message rescue JSON::ParserError message end end end end
Version data entries
12 entries across 12 versions & 1 rubygems