Update for form-urlencoded v5
Closed this issue ยท 7 comments
Related: #139
The specific issue there is fixed, but by making the current affjax error at compile time with the new form-urlencoded.
From what I gather, there's a bit of a design challenge here in that the request
signature doesn't currently have a way to surface an error that might occur when constructing an AjaxRequest
. Are there any ideas about what such an API should look like?
I think it's ok - the problem would occur before request, since it's when constructing the value for content
that this failure would occur - the appropriate constructor for RequestBody
expects a FormURLEncoded
typed value, it doesn't take a string and encode
that or anything.
I'll try doing the update now, I meant to do it ages ago but have had various things going on. Will find out quickly enough if it is a problem or not!
Ok, I'm not very good at reading comprehension obviously, since there's a line right there that says FormURLEncoded.encode
๐. I'll figure something out though, only just started looking.
I think I'm going to change the design a bit in a way that will help with a footgun affjax has right now: when an error occurs making the XHR request, it explodes using the Aff error channel (like in #128). So I'm going to make a Result
ADT for request
than can encompass a couple of different possibilities:
- Request content error (for this new case)
- XHR error (for catching throws when making the XHR request - bad URLs, things like that)
- Response format error (this is captured as a
Response (Either ...)
right now - it will still have the response attached, but with aForeign
body since decoding it failed) - Success
It means there'll be a bit more ceremony to handling results, but at least it will cover all the possible failure states now, and won't have to fall back on silently disappearing request content that is bad or something.