From 05376ed6bd37013902b180f6c9caddaaadd6dba3 Mon Sep 17 00:00:00 2001 From: David Celis Date: Wed, 27 Mar 2013 11:31:14 -0700 Subject: [PATCH] Don't use Exception, use StandardError It's bad Ruby practice to have Error classes inherit directly from Exception, or to raise instances of Exception itself. It is highly recommended that any custom error classes inherit instead from StandardError. StandardError is also the go-to exception class for when you need to raise an error without a custom class. Signed-off-by: David Celis --- lib/onelogin/ruby-saml/logoutresponse.rb | 4 ++-- lib/onelogin/ruby-saml/validation_error.rb | 2 +- test/logoutresponse_test.rb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/onelogin/ruby-saml/logoutresponse.rb b/lib/onelogin/ruby-saml/logoutresponse.rb index a9a39d140..db5bdbb6f 100644 --- a/lib/onelogin/ruby-saml/logoutresponse.rb +++ b/lib/onelogin/ruby-saml/logoutresponse.rb @@ -105,7 +105,7 @@ def valid_saml?(soft = true) if soft @schema.validate(@xml).map{ return false } else - @schema.validate(@xml).map{ |error| raise(Exception.new("#{error.message}\n\n#{@xml.to_s}")) } + @schema.validate(@xml).map{ |error| raise(StandardError.new("#{error.message}\n\n#{@xml.to_s}")) } end end @@ -151,4 +151,4 @@ def validation_error(message) end end end -end \ No newline at end of file +end diff --git a/lib/onelogin/ruby-saml/validation_error.rb b/lib/onelogin/ruby-saml/validation_error.rb index fd716964c..5bd839d80 100644 --- a/lib/onelogin/ruby-saml/validation_error.rb +++ b/lib/onelogin/ruby-saml/validation_error.rb @@ -1,6 +1,6 @@ module Onelogin module Saml - class ValidationError < Exception + class ValidationError < StandardError end end end diff --git a/test/logoutresponse_test.rb b/test/logoutresponse_test.rb index d3616a252..46bb44a4f 100644 --- a/test/logoutresponse_test.rb +++ b/test/logoutresponse_test.rb @@ -102,7 +102,7 @@ class RubySamlTest < Test::Unit::TestCase should "raise error for invalid xml" do logoutresponse = Onelogin::Saml::Logoutresponse.new(invalid_xml_response, settings) - assert_raises(Exception) { logoutresponse.validate! } + assert_raises(StandardError) { logoutresponse.validate! } end end