neondatabase / serverless

Connect to Neon PostgreSQL from serverless/worker/edge functions
https://www.npmjs.com/package/@neondatabase/serverless
MIT License
318 stars 11 forks source link

Export NeonDbError #42

Closed tmrclark closed 11 months ago

tmrclark commented 11 months ago

Can NeonDbError be included in the package exports to allow for instanceof narrowing in catch blocks like this.

import { NeonDbError } from '@neondatabase/serverless';
...
catch (e: unknown) {    
  if (e instanceof NeonDbError) {
     // Do something
  }
}
...
jawj commented 11 months ago

Absolutely! I thought I'd done this already, but it must have slipped through the net. I'll release a new driver version shortly.

jawj commented 11 months ago

This is now in @neondatabase/serverless@0.5.7. Do let me know if you have any trouble with it.

tmrclark commented 11 months ago

Thank you!