DEV: Return 400 instead of 500 for invalid top period (PR #13828)

This change will prevent a fatal 500 error when passing in an invalid period param value to the /top route.


The trouble with this is that a NoMethodError may be raised during the course of executing the method. How about checking with respond_to? first?

1 Like

Is is possible to validate the period variable instead of checking whether a method has been defined?

Yea, totally. I originally just went with the NoMethodFound because it wouldn’t be defined if it wasn’t in the period table, but yea there could be issues with that. I’ll just check if its a valid period value.