martini-contrib / binding

Martini handler for mapping and validating a raw request into a structure.
MIT License
140 stars 47 forks source link

External Use of binding errors struct #14

Closed kristian-puccio closed 10 years ago

kristian-puccio commented 10 years ago

I'm using martini and the binding package with Angular.

So if a requests fails the validation Angular gets back a binding.Errors() object which is all good.

What I'd like to do is to reuse the same error structure for other errors that might arise in the app basically so that I can have a consistent error checking experience with Angular. Say if the if I need to say a DB error occurred or something.

I'm currently doing this as Errors is exported, I just wanted to check my approach and wonder if we could formalise it or something so I don't feel so hacky.

Any thoughts?

Thanks

mholt commented 10 years ago

Binding doesn't have any other built-in structures for handling errors, so you're welcome to continue doing that if you'd like. Alternatively, you could design your own error struct that has a similar structure as the binding one, and maybe even more fields/data than the binding one provides, if you need it.