Comments (6)
I think the deal was that sometimes there is no status code? I honestly don't remember.
I've made a change on the http-errors branch of the repository and released it as 3.6.0-RC6-SNAPSHOT (sha fcd08f7). It lets you override that behavior.
If that works, let me know and I'll merge it.
If you see some other data that the preprocessor should have, then we can also consider adding it to the signature
from fulcro.
I tested your branch and it works ok.
I thought swapping merge parameters to (merge {:status-code 500} error-result)
would be enough. It provides a default value for status-code but does not replace it. But I do not know how much code of other applications depends on error code being equal to 500.
On the other hand there is also was-network-error?
function and remote-error
in app definition. So if users stick to defaults, they should be fine.
Some random thoughts / alternative solutions to new hook function:
a. one can go through all places of error-handler calls and add :status-code 500 there
b. extract-response
function can store http status in two keys - :status-code and :http-status-code where status-code can be updated by middleware / handlers, http-status-code will be always returned original http response code
c. there is also response-middleware so I would expect this could be the place for adding default status-codes
d. rather than adding preprocess-error you can allow users to override error-handler. The benefit of providing error-handler is, one can remove log/errors printing references to Fulcro code in console
Just my $0.02. I do not want to overengineer this part. Just had a feeling there are too many hooks and callbacks.
from fulcro.
Sorry I closed the issue by accident
from fulcro.
Right, reordering the merge is a breaking change, so I won't do that.
I like (b), but the change I made allows you to look at the actual result and "do whatever", so it is maximally flexible at that layer at least, but you are right that being able to sub the error-handler is probably too complex, given that you could just copy the entire remote and change it however you want.
You're right that the middleware is a good place to process the response in some way, and I do expect that. The constraint of not wanting to make breaking changes it the main critical concern for me, and the current remote has been working for me in production products for years. So, I'm not terribly concerned about expanding the functionality a lot.
That said, I'll give it a bit more consideration, because once I release this, then I'm stuck with it :D
from fulcro.
As I wrote I was able to make a workaround using response midleware:
(defn wrap-response-save-error
[handler]
(let [handler (or handler (http-remote/wrap-fulcro-response))]
(fn [response]
(let [response (handler response)]
(if-let [status-code (:status-code response)]
(assoc response :http-status-code status-code)
response)))))
I am fine with preprocess-error
solution. I just had a impression there are too many hooks, when general solution exist is enough.
from fulcro.
Fixed by PR #530
from fulcro.
Related Issues (20)
- eb/error-bondary breaks Fulcro Inspect's element picker
- Unnecessary re-rendering HOT 3
- Denormalize should not "detect loop" for leaf entities HOT 2
- Associate a list of components with a different instance of a state machine each HOT 1
- Mutation params are "closed over" on mutation submission, which causes problem in result actions. HOT 9
- Warnings about missing initial state for anonymous components with a `:componentName` HOT 7
- `comp/get-query` not correct when using raw component and union query HOT 4
- Fix text area and table examples exploding width HOT 2
- Fulcro 3.6 w/React 18
- http error 404 on github-pages HOT 2
- Fulcro 3.6 use of React Context breaks shouldComponentUpdate optimizations HOT 9
- Potentially add "Accept: application/transit+json" header. HOT 1
- Potentially omitted :force-root in `schedule-render!` HOT 5
- dr/change-route-relative! -- denied route does not call :route-denied component option HOT 1
- Dependency issue with taoensso.encore/dissoc-in HOT 2
- fs/dirty-fields misses recursive field HOT 1
- Link/ident queries don't work with `false` values
- dynamic routing question HOT 1
- HTTP middleware for making load/mutations work easily with JSON http APIs.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fulcro.