Skip to content

Commit

Permalink
feat: capture errors with sentry
Browse files Browse the repository at this point in the history
  • Loading branch information
cptchloroplast committed Sep 10, 2024
1 parent b1e7eb0 commit aedd3a5
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@okkema/worker",
"version": "3.0.3",
"version": "3.1.0",
"description": "Cloudflare Workers Toolkit",
"files": [
"dist"
Expand Down
2 changes: 1 addition & 1 deletion src/core/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type APIVariables = AuthVariables
export function API<
Bindings extends APIBindings,
Variables extends APIVariables,
>({ tokenUrl, options, scopes }: APIInit | undefined) {
>({ tokenUrl, options, scopes }: APIInit) {
const base = new Hono<{ Bindings: Bindings; Variables: Variables }>()
const app = fromHono(base, options)

Expand Down
2 changes: 2 additions & 0 deletions src/middleware/error.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { Context } from "hono"
import { Problem } from "../core"
import { captureException } from "@sentry/cloudflare"

export async function error(error: Error, c: Context) {
console.log(error)
captureException(error)
if (!c.env.DEBUG) return c.text("Internal Server Error", { status: 500 })
if (error instanceof Problem) return error.response
else
Expand Down

0 comments on commit aedd3a5

Please sign in to comment.