Coder Social home page Coder Social logo

Comments (2)

kevva avatar kevva commented on August 23, 2024

@huozhi, I know you worked on the onRequestError feature. How would you advice handling cases like this where you need to know which kind of error that was thrown? Maybe I don't want to log all errors, maybe I have some other logic for some other errors.

const onRequestError = error => {
  if (error instanceof MyCustomError) {
    doSomeThingDifferent();
    return;
  }

  console.error(error);
};

If you want to keep error as a DigestError, the source error could be added to the context or something.

from next.js.

huozhi avatar huozhi commented on August 23, 2024

If you're throwing an error in RSC layer, the error will be processed by react renderer and then being collected by the error reporter. So far we cannot get the actual instance or class of it as the thrown one could be anything and React needs to serialize it to a general error that can also be sent to client. From bundling perspective, the MyCustomerError is also bundled separately in the instrumentation entry and the page entry, they would beccome two separate classes. So instanceof might not work as expected here.

You could give it some other special property for example digest property that it will still be reused by react renderer and preserved during rendering serialization.

from next.js.

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.