MCPcopy Create free account
hub / github.com/nodejs/undici / errorHandlingExample

Function errorHandlingExample

docs/examples/socks5-proxy.js:134–148  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

132
133// Example with error handling
134async function errorHandlingExample () {
135 console.log('\n=== Error Handling Example ===')
136
137 try {
138 // Intentionally use a non-existent proxy
139 const socks5Proxy = new Socks5Agent('socks5://localhost:9999')
140
141 await request('http://httpbin.org/ip', {
142 dispatcher: socks5Proxy
143 })
144 } catch (error) {
145 console.log('Caught expected error:', error.message)
146 console.log('Error code:', error.code)
147 }
148}
149
150// Global dispatcher example
151async function globalDispatcherExample () {

Callers 1

runExamplesFunction · 0.85

Calls 1

requestFunction · 0.50

Tested by

no test coverage detected