Skip to content

Commit

Permalink
fix: add sentry exception to ucanto server catch (#70)
Browse files Browse the repository at this point in the history
This was missing from #59 and errors happening within ucanto service
were not being propagated to sentry
  • Loading branch information
vasco-santos authored Dec 8, 2022
1 parent 84323a8 commit c7092c7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions api/service/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import * as Server from '@ucanto/server'
import * as CAR from '@ucanto/transport/car'
import * as CBOR from '@ucanto/transport/cbor'
import * as Sentry from '@sentry/serverless'

import { createStoreService } from './store/index.js'
import { createUploadService } from './upload/index.js'

Sentry.AWSLambda.init({
dsn: process.env.SENTRY_DSN,
tracesSampleRate: 1.0,
})

/**
* @param {import('./types').UcantoServerContext} context
* @returns {import('./types').Service}
Expand All @@ -27,8 +33,8 @@ export function createServiceRouter (context) {
decoder: CAR,
service: createServiceRouter(context),
catch: (/** @type {string | Error} */ err) => {
// TODO: We need sentry to log stuff
console.log('reporting error to sentry', err)
console.warn(err)
Sentry.AWSLambda.captureException(err)
},
})

Expand Down

0 comments on commit c7092c7

Please sign in to comment.