Error Handling Conventions changed?

18 views
Skip to first unread message

brandon.bowersox-johnson

unread,
Nov 1, 2017, 4:01:09 PM11/1/17
to OpenLMIS Dev
Hi Dev Forum,

I see that the Requisition Service responds with a JSON error message that does not follow our documented conventions. JSON and links below with details.

Is there a reason we changed our convention? Do we need to either update our convention or go back and update Requisition Service to follow the pre-existing convention?

JSON today from a Requisition Service 400 Bad Request:

{
    "requisitionLineItems": "requisition.error.validation.reasonNotInRequisitionReasonList: Requisition cannot be saved because of adjustment reason with id d9aa0af6-f7f8-4aab-908f-15c660493be5 not being present on the list of allowed reasons."
}

Error Handling Convention JSON:

{
  "message" : "Action prohibited because user does not have permission at the facility",
  "messageKey" : "requisition.error.prohibited.noFacilityPermission"
}

OpenLMIS Error Handling Convention:

Perhaps the reason for changing the JSON structure was to allow an Array of multiple errors returned on a single request. Our conventions document still has that flagged under "Future: Arrays of Messages" as something we need to establish a convention for. If we are going to make a convention for that, I would still suggest we want the messageKey and the message string as separate properties in the JSON so that API consumers can get each piece without parsing/regex'ing a string.

-Brandon

Paweł Albecki

unread,
Nov 1, 2017, 9:18:16 PM11/1/17
to OpenLMIS Dev
Hi,

I don't think any convention was changed. The pattern for requisition validation errors was there from the beginning: https://github.com/OpenLMIS/openlmis-requisition/commit/64e31f05ee4c3f44950ea586a09c441f6ab429e7. I don't know why it wasn't changed yet to follow conventions, maybe because convention has missing part about array of errors. In April, we started a discussion in Dev Group: https://groups.google.com/forum/#!topic/openlmis-dev/iwGo2mLR3wk. Maybe it's a good time to follow-up.

Paweł

--
You received this message because you are subscribed to the Google Groups "OpenLMIS Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openlmis-dev+unsubscribe@googlegroups.com.
To post to this group, send email to openlm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openlmis-dev/6fc19461-a3c7-446e-8e93-03e9bb3837a4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Paweł Albecki
Software Developer
palb...@soldevelo.com



SolDevelo
Sp. z o.o. [LLC] / www.soldevelo.com
Al. Zwycięstwa 96/98, 81-451, Gdynia, Poland
Phone: +48 58 782 45 40 / Fax: +48 58 782 45 41

Reply all
Reply to author
Forward
0 new messages