Sean, if you were to Spec your API responses, what would you do for your error 
response?

This is my issue. I operate in a distributed environment. If I produce a set of 
data, but one field failed to compute properly, maybe a downstream system was 
down, maybe some information I was given to compute was corrupted, or missing, 
etc. And say this producing service has no user facing component, failing it is 
not logical. So I need to publish the partial result, and the error field 
should indicate an error. In my case it publishes a document entry in a nosql 
datastore, and events about it.

Now, some other system will eventually consume that document, to display it to 
the user. When it does, it must appropriately handle the fact that some fields 
were in error.

My documents are fully specced. So that consuming services can easily know 
their shapes and structure, so they can be sure to support them fully.

In such scenario, exceptions aren't useful, but only because Java exceptions 
are crap at serialization. So I need to do the same thing you are, marshal my 
exception into an error and serialize that into my document. Then I spec the 
field appropriately. 

Now, I feel a lot of people using Spec would have such a use case, as its a 
logical tool to model data at your boundaries, and so I felt it might make 
sense to offer a spec macro for it.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to