From d6e63263a52eb16aaa86bbbe36a5ec60c1ac8e49 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Franti=C5=A1ek=20Dvo=C5=99=C3=A1k?= Date: Tue, 14 Jun 2016 14:26:20 +0200 Subject: [PATCH] Ruby: better way of using of the exeptions (message variable already there). --- .rubocop.yml | 5 ----- lib/error.rb | 5 ++--- lib/nebula.rb | 2 +- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 1ec3868..7378663 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -74,11 +74,6 @@ Style/MutableConstant: Style/NegatedIf: Enabled: false -# Provide an exception class and message as arguments to raise -# (wtf) -Style/RaiseArgs: - Enabled: false - # Redundant return detected # (easy to read) Style/RedundantReturn: diff --git a/lib/error.rb b/lib/error.rb index 219b5ae..4f24575 100644 --- a/lib/error.rb +++ b/lib/error.rb @@ -2,11 +2,10 @@ module Now # The main exception class for NOW. class NowError < StandardError - attr_accessor :code, :message + attr_accessor :code - def initialize(code, message) + def initialize(code) @code = code - @message = message end end diff --git a/lib/nebula.rb b/lib/nebula.rb index 4c2c1cb..6419da8 100644 --- a/lib/nebula.rb +++ b/lib/nebula.rb @@ -129,7 +129,7 @@ module Now end code = error_one2http(return_code.errno) - raise NowError.new(code, return_code.message) + raise NowError.new(code), return_code.message end end -- 1.8.2.3