Sha256: 6301471f5782aab45aae44cfb95097718e4e476c9ba7bb47da40fdd5a5ca1491

Contents?: true

Size: 647 Bytes

Versions: 6

Compression:

Stored size: 647 Bytes

Contents

require "json"
module Gitea
  module Api 
    class ServerError < Common::Exception 
      attr_reader :http_code, :error_code, :message 

      def initialize(response)
        @http_code = response.code 
        @attrs = JSON.parse(response.body) rescue {}
        @message = @attrs['message']
      end

      def to_s
        @attrs.delete('documentation_url')
        @attrs.merge({'HTTPCode' => @http_code}).map do |k, v|
          [k, v].join(": ")
        end.join(", ")
      end
    end

    class CallBackError < ServerError 
    end # CallBackError

    class ClientError < Common::Exception
    end # ClientError
  end # Api
end # Git

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
gitea-client-1.6.1 lib/gitea/api/exception.rb
gitea-client-1.6.0 lib/gitea/api/exception.rb
gitea-client-1.5.9 lib/gitea/api/exception.rb
gitea-client-1.5.8 lib/gitea/api/exception.rb
gitea-client-1.5.6 lib/gitea/api/exception.rb
gitea-client-1.5.0 lib/gitea/api/exception.rb