3 ms·
I wonder if there's some architectural reason for using `["Status", {}]` shapes instead of a more traditional response shape [ "Ok", {
by mdaniel 3y ago
I wonder if there's some architectural reason for using `["Status", {}]` shapes instead of a more traditional response shape
[
"Ok",
{
"data": {
It seems to place a lot of the error detection burden upon the caller, since the response can be empty `[]`, it can have a status without a body (which, I guess may be fine for their api?) `["OkHarHar"]`, and then the usual promises-made-promises-kept of the expected keys being in the `response[1]` location. One can see this heartache sort of play out in the subsequent python code in the blog post although they just return None in the simple `len() != 2` case
- akiselev 3y agoWith pattern matching it'd look like: match (response) { ["Ok", { data }] => { ... }, ["Error", { error }] => { ...handle known error... } _ => { ...handle unknown error... }, } It could also just be auto-generated serialization/deserialization code like in Rust.