sinatra-param
sinatra-param copied to clipboard
Fix NoMethodError, TypeError in coerce when unexpected Array or Hash
Exception examples that are prevented (to check can comment fixing code in coerce and run tests):
TypeError:
can't convert Array into Integer
TypeError:
can't convert Array into Float
NoMethodError:
undefined method `split' for ["1", "2", "3"]:Array
TypeError:
can't convert Hash into Integer
TypeError:
can't convert Hash into Float
NoMethodError:
undefined method `split' for {"a"=>"b"}:Hash
Thanks for the patch, @shhavel, and apologies for the delay in reviewing it.
I'm hesitant to rescue on something as broad as NoMethodError, since it might obscure underlying issues. Could we refactor the implementation to do a more specific check instead?
@mattt Updated branch - added one check instead of rescue NoMethodError . Thanks