Wednesday, 24 May 2017

When to propagate errors from client network framework to upper levels

I have a pattern question on how to propagate errors in general. Lets say I have a REST API framework that sends GET requests and the response I parse using JSON parser into my object model. If the parser finds a nil, should it propagate an error or just assign the parsed value a nil/null? Are there cases errors should propagated instead of jus assigning a value within the model to nil?

It seems I'm answering my own question here, which is if there is a strict requirement where a value cannot be nil, I should an error up the stack. But if I propagate errors, I may make the system less flexible by not allowing the upper layers to handle special combinations.

Any experiences on this?



via mskw

No comments:

Post a Comment