Skip to content

Derive Exceptions from StandardError #112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/mqtt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module MQTT
DEFAULT_SSL_PORT = 8883

# Super-class for other MQTT related exceptions
class Exception < ::Exception
class Exception < StandardError
end

# A ProtocolException will be raised if there is a
Expand Down
23 changes: 23 additions & 0 deletions spec/mqtt_exception_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
$:.unshift(File.dirname(__FILE__))

require 'spec_helper'
require 'mqtt'

describe MQTT do

describe "mqtt exceptions" do
it "should be a ruby standard error" do
expect(MQTT::ProtocolException.new).to be_a(StandardError)
expect(MQTT::NotConnectedException.new).to be_a(StandardError)
expect(MQTT::SN::ProtocolException.new).to be_a(StandardError)
end

it "should be an mqtt error" do
expect(MQTT::ProtocolException.new).to be_a(MQTT::Exception)
expect(MQTT::NotConnectedException.new).to be_a(MQTT::Exception)
expect(MQTT::SN::ProtocolException.new).to be_a(MQTT::Exception)
end

end

end