scarpe-team / scarpe

Scarpe - shoes but running on webview

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Find raise statements with strings and add an error subclass

noahgibbs opened this issue · comments

It would be good to use a specific subclass of Shoes::Error or Scarpe::Error for every error raised. Right now, mostly we're raising simple StandardErrors with strings.

So things like this:

      unless categories.is_a?(Hash)
        raise("Please supply a hash with categories names as keys and an array of two-elt arrays as values!")
      end

would be better if we had a Scarpe::Error subclass called something like Scarpe::ArgumentError, and then raise that instead of a normal StandardError.

Right now it's hard to usefully catch errors by subtype, because there aren't any subtypes.

Hey @noahgibbs - Hope you are doing good. I'd like to work on this issue. Can you please assign it to me? Thanks. :)

Sure! Assigned.

Heya! I've merged a PR that touches a lot of lines. You may want to rebase over that -- it shouldn't touch many of the same lines you did, but it will touch a lot of the same files.

Let me know if I can help with the merge!

Hey @noahgibbs - I've rebased my branch. It went smoothly. Thanks for letting me know :)

Hey @noahgibbs - I noticed that there are some raise statements in example projects as well. Do we want to create error classes for those as well?

Anything under "legacy" we try not to change, so don't modify those. Examples outside the "legacy" directory are fair game if you like, but not a priority.

Hey @noahgibbs - Sorry for being so late on this, I got occupied with office stuff. Now that I've got a window, I'll deliver it as soon as possible.
I've just pushed a commit that creates the custom error classes for all the raise statements under the /lib folder. Would love to your thoughts on it. Thanks.

All good. We're not on the clock here :-)

The commit I see with the new exceptions file looks good. I'm assume you also have (or will have) a bunch of changes to wrap up the error strings in those where we raise. But yeah, that definitely lines up with what I was thinking when I wrote this bug.

Thank you!

Hey @noahgibbs - A PR for this issue is now ready for review. Would love to hear your thoughts on it. Thanks. :)