1
0

exceptions.rb 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # frozen_string_literal: true
  2. module Mastodon
  3. class Error < StandardError; end
  4. class NotPermittedError < Error; end
  5. class ValidationError < Error; end
  6. class HostValidationError < ValidationError; end
  7. class LengthValidationError < ValidationError; end
  8. class DimensionsValidationError < ValidationError; end
  9. class StreamValidationError < ValidationError; end
  10. class RaceConditionError < Error; end
  11. class RateLimitExceededError < Error; end
  12. class SyntaxError < Error; end
  13. class InvalidParameterError < Error; end
  14. class UnexpectedResponseError < Error
  15. attr_reader :response
  16. def initialize(response = nil)
  17. @response = response
  18. if response.respond_to? :uri
  19. super("#{response.uri} returned code #{response.code}")
  20. else
  21. super
  22. end
  23. end
  24. end
  25. class PrivateNetworkAddressError < HostValidationError
  26. attr_reader :host
  27. def initialize(host)
  28. @host = host
  29. super()
  30. end
  31. end
  32. HTTP_CONNECTION_ERRORS = [
  33. HTTP::ConnectionError,
  34. HTTP::Error,
  35. HTTP::TimeoutError,
  36. OpenSSL::SSL::SSLError,
  37. ].freeze
  38. end