sinatra-param icon indicating copy to clipboard operation
sinatra-param copied to clipboard

Fix NoMethodError, TypeError in coerce when unexpected Array or Hash

Open shhavel opened this issue 9 years ago • 2 comments

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

shhavel avatar Apr 20 '16 20:04 shhavel

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 avatar Mar 20 '18 15:03 mattt

@mattt Updated branch - added one check instead of rescue NoMethodError . Thanks

shhavel avatar Mar 23 '18 10:03 shhavel