Coder Social home page Coder Social logo

Comments (6)

awkay avatar awkay commented on June 11, 2024

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.

danskarda avatar danskarda commented on June 11, 2024

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.

danskarda avatar danskarda commented on June 11, 2024

Sorry I closed the issue by accident

from fulcro.

awkay avatar awkay commented on June 11, 2024

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.

danskarda avatar danskarda commented on June 11, 2024

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.

awkay avatar awkay commented on June 11, 2024

Fixed by PR #530

from fulcro.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.