mirror of
https://github.com/urbit/shrub.git
synced 2025-01-04 10:32:34 +03:00
refactors http error-handling in lib/{stdio,tapp}
This commit is contained in:
parent
3050bae263
commit
88e2bfe5c3
@ -71,27 +71,44 @@
|
||||
;< ~ bind:m (send-raw-card %hiss / ~ %httr %hiss hiss)
|
||||
(set-raw-contract & %hiss ~)
|
||||
::
|
||||
:: Wait until we get an HTTP response
|
||||
:: Wait until we get an HTTP response or error
|
||||
::
|
||||
++ take-sigh-raw
|
||||
=/ m (async ,httr:eyre)
|
||||
=/ m (async (each httr:eyre tang))
|
||||
^- form:m
|
||||
|= =async-input
|
||||
:^ ~ ~ ~
|
||||
?~ in.async-input
|
||||
[%wait ~]
|
||||
?. ?=(%sigh -.sign.u.in.async-input)
|
||||
[%fail %expected-sigh >got=-.sign.u.in.async-input< ~]
|
||||
[%done httr.sign.u.in.async-input]
|
||||
=* sign sign.u.in.async-input
|
||||
?: ?=(%sigh -.sign)
|
||||
[%done %& httr.sign]
|
||||
?: ?=(%sigh-tang -.sign)
|
||||
[%done %| tang.sign]
|
||||
[%fail %expected-sigh >got=-.sign< ~]
|
||||
::
|
||||
:: Wait until we get an HTTP response and unset contract
|
||||
::
|
||||
++ take-sigh
|
||||
=/ m (async ,httr:eyre)
|
||||
^- form:m
|
||||
;< =httr:eyre bind:m take-sigh-raw
|
||||
;< ~ bind:m (set-raw-contract | %hiss ~)
|
||||
(pure:m httr)
|
||||
;< rep=(each httr:eyre tang) bind:m take-sigh-raw
|
||||
;< ~ bind:m (set-raw-contract | %hiss ~)
|
||||
?- -.rep
|
||||
%& (pure:m p.rep)
|
||||
::
|
||||
%| |= =async-input
|
||||
[~ ~ ~ %fail %sigh-tang p.rep]
|
||||
==
|
||||
::
|
||||
:: Wait until we get an HTTP response or error and unset contract
|
||||
::
|
||||
++ take-sigh-each
|
||||
=/ m (async (each httr:eyre tang))
|
||||
^- form:m
|
||||
;< rep=(each httr:eyre tang) bind:m take-sigh-raw
|
||||
;< ~ bind:m (set-raw-contract | %hiss ~)
|
||||
(pure:m rep)
|
||||
::
|
||||
:: Extract body from raw httr
|
||||
::
|
||||
|
@ -389,7 +389,7 @@
|
||||
++ sigh-tang
|
||||
|= [=wire =tang]
|
||||
^- (quip move _this-tapp)
|
||||
(oob-fail-async %failed-sigh tang)
|
||||
(take-async bowl `[wire %sigh-tang tang])
|
||||
::
|
||||
:: Pass timer to async, or fail
|
||||
::
|
||||
|
@ -18,6 +18,7 @@
|
||||
::
|
||||
+$ sign
|
||||
$% [%sigh =httr:eyre]
|
||||
[%sigh-tang =tang]
|
||||
[%wake error=(unit tang)]
|
||||
[%coup =dock error=(unit tang)]
|
||||
[%quit =dock =path]
|
||||
|
Loading…
Reference in New Issue
Block a user