Skip to content

Commit e5e94be

Browse files
committed
Expose PuppeteerExtraPluginRecaptcha error
1 parent 523b2ef commit e5e94be

File tree

1 file changed

+10
-1
lines changed
  • packages/puppeteer-extra-plugin-recaptcha/src

1 file changed

+10
-1
lines changed

packages/puppeteer-extra-plugin-recaptcha/src/index.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,16 @@ export class PuppeteerExtraPluginRecaptcha extends PuppeteerExtraPlugin {
235235
)
236236
}
237237
if (this.opts.throwOnError && response.error) {
238-
throw new Error(response.error)
238+
const { error } = response
239+
const { error: message } = error
240+
// build custom error so consumers can evaluate its properties
241+
const customError = new Error(message)
242+
for (const key in error) {
243+
if (Object.prototype.hasOwnProperty.call(error, key)) {
244+
customError[key] = error[key]
245+
}
246+
}
247+
throw customError
239248
}
240249
return response
241250
}

0 commit comments

Comments
 (0)