I would likely only spec the status 200 OK responses. We use 400-series status 
values when we send back an error. You might consider that to be the 
“exception” of the HTTP world 😊



We actually do have a documented format for 400-series responses but pretty 
much any part can be omitted so callers might occasionally not be able to 
ascertain a reason beyond “it failed”…



Sean Corfield -- (970) FOR-SEAN -- (904) 302-SEAN
An Architect's View -- http://corfield.org/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood



________________________________
From: clojure@googlegroups.com <clojure@googlegroups.com> on behalf of Didier 
<didi...@gmail.com>
Sent: Friday, October 26, 2018 11:35:20 AM
To: Clojure
Subject: RE: An Error spec?

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.

-- 
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