Sha256: 2c14c42909a9e8dd4b86886bd939a57763cec19ed947ae74717fb6c47d2de0e6
Contents?: true
Size: 1.01 KB
Versions: 49
Compression:
Stored size: 1.01 KB
Contents
# frozen_string_literal: true module DjiMqttConnect # Represents an Error caused when communicatng via MQTT class Error < StandardError attr_reader :wrapped_exception def initialize(error, message = nil) @wrapped_exception, msg = error_and_message(error, message) super(msg) end def backtrace if @wrapped_exception @wrapped_exception.backtrace else super end end def inspect if @wrapped_exception inner = +"" inner += ": #{message}," if !message.empty? && @wrapped_exception.message != message inner << " wrapped=#{@wrapped_exception.inspect}" %(#<#{self.class}#{inner}>) else super end end private # Pulls out potential parent exception and response hash. def error_and_message(exc, message) return [exc, message || exc.message] if exc.respond_to?(:backtrace) [nil, exc.to_s] end end # Indicates a problem parsing a response class ParseError < Error end end
Version data entries
49 entries across 49 versions & 1 rubygems