Skip to content

Commit

Permalink
Expose PuppeteerExtraPluginRecaptcha error
Browse files Browse the repository at this point in the history
  • Loading branch information
markcellus committed Oct 26, 2022
1 parent 523b2ef commit f351109
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/puppeteer-extra-plugin-recaptcha/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,16 @@ export class PuppeteerExtraPluginRecaptcha extends PuppeteerExtraPlugin {
)
}
if (this.opts.throwOnError && response.error) {
throw new Error(response.error)
const { error } = response
const { error: message } = error
// build custom error so consumers can evaluate its properties
const customError = new Error(message)
for (const key in error) {
if (Object.prototype.hasOwnProperty(key)) {
customError[key] = error[key]
}
}
throw customError
}
return response
}
Expand Down

0 comments on commit f351109

Please sign in to comment.