meteor-space / base

Foundation for Modular Application Architecture in Meteor.
MIT License
75 stars 5 forks source link

Space.Error should have field of type Object for encapsulation of erroneous data #42

Open darko-mijic opened 8 years ago

darko-mijic commented 8 years ago

I think Space.Error needs a built in field of type Object to support encapsulation of invalid data.

For i18n purposes name of the error class instance + data that is wrong (causing the error) can be enough to generate language specific error message.

I suggest adding something like this to default fields of Space.Error: data: Match.Optional(Object)

Maybe the name of this field is not ideal.

What do you think @rhyslbw and @DominikGuzei?

DominikGuzei commented 8 years ago

Hmm … the question is, is it necessary to add a general purpose field when you can just add it to any custom error type? Then you can also have more specific field names that make sense in the context.

rhyslbw commented 8 years ago

@darko-mijic All up for standardising fields, maybe even as optional, but not keen on generic objects. What are the specific properties of these proposed 'data' objects?

darko-mijic commented 8 years ago

My idea was to have optional object that will contain relevant data that caused the error. I was adding that to almost all my subclasses of Space.Error (my custom error types). So the error presented to the client would include i18n message + data from the proposed field.