Skip to content
This repository has been archived by the owner on Jun 18, 2019. It is now read-only.

Make initializer for UnboxError public #142

Merged
merged 1 commit into from Nov 21, 2016

Conversation

JRG-Developer
Copy link
Contributor

This PR makes the initializer for UnboxError public so that consumers can create their own custom UnboxError if desired.

This is a quick fix solution to #136, which I imagine will actually suffice for many/most consumers.

@JRG-Developer
Copy link
Contributor Author

Thoughts on this?

@JohnSundell
Copy link
Owner

Hey @JRG-Developer, sorry for taking a long time to review this. I actually fail to see how this solves the issue at hand, since that issue is about not being able to get the specific error that occured anymore (because the error API was heavily simplified in Unbox 2.2) - at least that's how I understand it. Not sure I see any usecases where you'd want to manually create an UnboxError instance, but feel free to correct me if I'm wrong 😄

@danielgalasko
Copy link

Yeah we actually encountered this recently. It was really nice previously where we could just say throw UnboxError.invalidValue(someValue, "jsonKey") in an initialiser. Now all these calls had to be replaced with our own custom errors which just felt a little overkill.

It would be nice if we could just piggyback off the great set of Unbox errors in these instances were unboxing failed with trivial errors already supported privately by Unbox

@JRG-Developer
Copy link
Contributor Author

@JohnSundell

The issue is two fold:

  1. Being able to determine the specific error type... this isn't solved by this PR.

However, many apps (ours included) may not care about the type, just that something went wrong during unboxing... this leads to point (2).

  1. Being able to throw a custom "unboxing failed" error. As @danielgalasko mentioned, it was previously nice to be able to throw a custom UnboxError to indicate "something went wrong during unboxing."

While this could be done by throwing a different, custom Error, this would lead to checking for yet another type of Error, resulting in more complex code.

It's simpler to just allow consumers to create their own custom UnboxError, and AFAICT, there isn't really any downside to doing such. 😄

@JohnSundell
Copy link
Owner

@danielgalasko Yeah, I'm planning to bring back the previously public specific errors (that are now called UnboxPathError). My intention was to make the API simpler, but it backfired a bit 😅

@JohnSundell
Copy link
Owner

@JRG-Developer Alright, I see your point. Makes sense, let's merge this! 👍

@JohnSundell JohnSundell merged commit ed968bf into JohnSundell:master Nov 21, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants