Comments (2)
@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.
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)
- Cannot name a folder "index" inside the app directory.
- Using `revalidateTag()` inside dynamic route handler is unstable HOT 1
- Using `revalidateTag()` inside dynamic route handler is unstable HOT 2
- Cannot use import alias if route path starts with period
- Dynamic `import()` function usage behaves strangely, prevents server-only code HOT 1
- Client error with development message on PRODUCTION. HOT 1
- missing sourcemaps in app router and cannot debug with breakpoints HOT 1
- Docs: Learn Next.js Chapter 9 HOT 1
- next/link <Link> is not loading AMP page components from non-AMP page, I have to use <a> tag only then it renders AMP components which resets the router.
- Parent `loading` is not mounted when child's one is missing HOT 1
- Vercel deployment failed after commit changes to repository
- Error when using `experimental.workerThreads` and webpack config
- Time-based cache revalidation does not work when calling fetch with manually created Request object HOT 1
- Event listeners added multiple times on client-side HMR HOT 1
- Redirects don't work in production. The page times out HOT 5
- MQTT.JS example: the useEffect return cause client closure
- next/dynamic from external package causes hydration errors for combination of pages and app routers
- Licensing: 14.2.5 bundles MPL-licensed @vercel/og HOT 1
- Swc causing error in production. Related to citation-js and citeproc.
- Error in dev mode with turbopack using Chakra-UI components from server components HOT 2
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 next.js.