Skip to content

Commit

Permalink
refactor: only handle browser errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Sep 12, 2024
1 parent a0f4d79 commit 2c4a251
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions packages/errors/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,7 @@ browserlessError.ensureError = rawError => {
return require('ensure-error')(error)
}

const isBrowserlessError = error => error.name === ERROR_NAME

module.exports = browserlessError
module.exports.isBrowserlessError = isBrowserlessError
6 changes: 4 additions & 2 deletions packages/function/src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const { ensureError, browserTimeout } = require('@browserless/errors')
const { isBrowserlessError, ensureError, browserTimeout } = require('@browserless/errors')
const debug = require('debug-logfmt')('browserless:function')
const requireOneOf = require('require-one-of')
const pTimeout = require('p-timeout')
Expand Down Expand Up @@ -45,7 +45,9 @@ module.exports =

const result = await withVM()
if (result.isFulfilled) return result
throw ensureError(result.value)
const error = ensureError(result.value)
if (isBrowserlessError(error)) throw ensureError(error)
return result
}

const task = () =>
Expand Down

0 comments on commit 2c4a251

Please sign in to comment.