oRPC
background

Error Handling

How to intercept, handle or log errors inside oRPC

import { ,  } from '@orpc/server'
 
const  = 
    .((, , ) => {
        .(async () => {
            if(!( instanceof )) return;
 
            .(., ., .)
            // do something here
        })
 
        .(() => {})
        .((, ) => {})
    })
    .((, , ) => {
        throw new ({
            : 'NOT_FOUND',
            : 'Not found',
            : 404, // Optional: custom default behavior
            : { : 'include in the body and send to the client' } // pass data to the client
        })
    })

On this page

No Headings