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 c5df644
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 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,15 @@ export class PuppeteerExtraPluginRecaptcha extends PuppeteerExtraPlugin {
)
}
if (this.opts.throwOnError && response.error) {
throw new Error(response.error)
const { error } = response
// build custom error so consumers can evaluate its properties
const customError = new Error(response.error.error.message)
for (const key in error) {
if (Object.prototype.hasOwnProperty.call(error, key)) {
customError[key] = error[key]
}
}
throw customError
}
return response
}
Expand Down

0 comments on commit c5df644

Please sign in to comment.