Skip to content

Commit

Permalink
feat: onBug()
Browse files Browse the repository at this point in the history
  • Loading branch information
brillout committed May 10, 2022
1 parent 7df1b59 commit 2b1be00
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion telefunc/client/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export const getContext = err('getContext')
export const provideTelefuncContext = err('provideTelefuncContext')
export const Abort = err('Abort')
export const shield = err('shield')
export const onTelefuncServerError = err('onTelefuncServerError')
export const onBug = err('onBug')

import { assertUsage } from './utils'

Expand Down
2 changes: 1 addition & 1 deletion telefunc/node/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export { telefuncConfig } from './telefuncConfig'
export { getContext, provideTelefuncContext } from './getContext'
export { Abort } from './Abort'
export { shield } from './shield'
export { onTelefuncServerError } from './runTelefunc/onTelefuncServerError'
export { onBug } from './runTelefunc/onBug'

// In order to allow users to override `Telefunc.Context`, we need to export `Telefunc` (even if the user never imports `Telefunc`)
export type { Telefunc } from './getContext/TelefuncNamespace'
Expand Down
4 changes: 2 additions & 2 deletions telefunc/node/server/runTelefunc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { getTelefunctions } from './runTelefunc/getTelefunctions'
import { executeTelefunction } from './runTelefunc/executeTelefunction'
import { serializeTelefunctionResult } from './runTelefunc/serializeTelefunctionResult'
import { handleError } from './runTelefunc/handleError'
import { executeServerErrorListeners } from './runTelefunc/onTelefuncServerError'
import { callBugListeners } from './runTelefunc/onBug'
import { applyShield } from './runTelefunc/applyShield'
import { findTelefunction } from './runTelefunc/findTelefunction'
import { globalContext } from './globalContext'
Expand Down Expand Up @@ -39,7 +39,7 @@ async function runTelefunc(runContext: Parameters<typeof runTelefunc_>[0]) {
try {
return await runTelefunc_(runContext)
} catch (err: unknown) {
executeServerErrorListeners(err)
callBugListeners(err)
handleError(err, globalContext.viteDevServer || null)
return serverError
}
Expand Down
14 changes: 14 additions & 0 deletions telefunc/node/server/runTelefunc/onBug.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export { onBug }
export { callBugListeners }

const bugListeners: ((err: unknown) => void)[] = []

function onBug(listener: (err: unknown) => void) {
bugListeners.push(listener)
}

function callBugListeners(err: unknown) {
bugListeners.forEach((listener) => {
listener(err)
})
}
14 changes: 0 additions & 14 deletions telefunc/node/server/runTelefunc/onTelefuncServerError.ts

This file was deleted.

0 comments on commit 2b1be00

Please sign in to comment.