puppeteer/assets/js/508f41c7.6a401441.js
2021-10-07 15:21:45 +00:00

1 line
5.0 KiB
JavaScript

"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([[48068],{3905:function(e,r,t){t.d(r,{Zo:function(){return c},kt:function(){return m}});var p=t(67294);function n(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function o(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var p=Object.getOwnPropertySymbols(e);r&&(p=p.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,p)}return t}function a(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?o(Object(t),!0).forEach((function(r){n(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):o(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function i(e,r){if(null==e)return{};var t,p,n=function(e,r){if(null==e)return{};var t,p,n={},o=Object.keys(e);for(p=0;p<o.length;p++)t=o[p],r.indexOf(t)>=0||(n[t]=e[t]);return n}(e,r);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(p=0;p<o.length;p++)t=o[p],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(n[t]=e[t])}return n}var u=p.createContext({}),s=function(e){var r=p.useContext(u),t=r;return e&&(t="function"==typeof e?e(r):a(a({},r),e)),t},c=function(e){var r=s(e.components);return p.createElement(u.Provider,{value:r},e.children)},l={inlineCode:"code",wrapper:function(e){var r=e.children;return p.createElement(p.Fragment,{},r)}},f=p.forwardRef((function(e,r){var t=e.components,n=e.mdxType,o=e.originalType,u=e.parentName,c=i(e,["components","mdxType","originalType","parentName"]),f=s(t),m=n,d=f["".concat(u,".").concat(m)]||f[m]||l[m]||o;return t?p.createElement(d,a(a({ref:r},c),{},{components:t})):p.createElement(d,a({ref:r},c))}));function m(e,r){var t=arguments,n=r&&r.mdxType;if("string"==typeof e||n){var o=t.length,a=new Array(o);a[0]=f;var i={};for(var u in r)hasOwnProperty.call(r,u)&&(i[u]=r[u]);i.originalType=e,i.mdxType="string"==typeof e?e:n,a[1]=i;for(var s=2;s<o;s++)a[s]=t[s];return p.createElement.apply(null,a)}return p.createElement.apply(null,t)}f.displayName="MDXCreateElement"},86872:function(e,r,t){t.r(r),t.d(r,{frontMatter:function(){return i},contentTitle:function(){return u},metadata:function(){return s},toc:function(){return c},default:function(){return f}});var p=t(87462),n=t(63366),o=(t(67294),t(3905)),a=["components"],i={},u=void 0,s={unversionedId:"puppeteer.puppeteer.errors",id:"version-9.1.1/puppeteer.puppeteer.errors",isDocsHomePage:!1,title:"puppeteer.puppeteer.errors",description:"Home &gt; puppeteer &gt; Puppeteer &gt; errors",source:"@site/versioned_docs/version-9.1.1/puppeteer.puppeteer.errors.md",sourceDirName:".",slug:"/puppeteer.puppeteer.errors",permalink:"/puppeteer/docs/9.1.1/puppeteer.puppeteer.errors",editUrl:"https://github.com/facebook/puppeteer/edit/main/website/versioned_docs/version-9.1.1/puppeteer.puppeteer.errors.md",version:"9.1.1",frontMatter:{},sidebar:"version-9.1.1/docs",previous:{title:"puppeteer.puppeteer.devices",permalink:"/puppeteer/docs/9.1.1/puppeteer.puppeteer.devices"},next:{title:"puppeteer.puppeteer.networkconditions",permalink:"/puppeteer/docs/9.1.1/puppeteer.puppeteer.networkconditions"}},c=[{value:"Puppeteer.errors property",id:"puppeteererrors-property",children:[]},{value:"Remarks",id:"remarks",children:[]},{value:"Example",id:"example",children:[]}],l={toc:c};function f(e){var r=e.components,t=(0,n.Z)(e,a);return(0,o.kt)("wrapper",(0,p.Z)({},l,t,{components:r,mdxType:"MDXLayout"}),(0,o.kt)("p",null,(0,o.kt)("a",{parentName:"p",href:"/puppeteer/docs/9.1.1/index"},"Home")," ",">"," ",(0,o.kt)("a",{parentName:"p",href:"/puppeteer/docs/9.1.1/puppeteer"},"puppeteer")," ",">"," ",(0,o.kt)("a",{parentName:"p",href:"/puppeteer/docs/9.1.1/puppeteer.puppeteer"},"Puppeteer")," ",">"," ",(0,o.kt)("a",{parentName:"p",href:"/puppeteer/docs/9.1.1/puppeteer.puppeteer.errors"},"errors")),(0,o.kt)("h2",{id:"puppeteererrors-property"},"Puppeteer.errors property"),(0,o.kt)("b",null,"Signature:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-typescript"},"get errors(): PuppeteerErrors;\n")),(0,o.kt)("h2",{id:"remarks"},"Remarks"),(0,o.kt)("p",null,"Puppeteer methods might throw errors if they are unable to fulfill a request. For example, ",(0,o.kt)("inlineCode",{parentName:"p"},"page.waitForSelector(selector[, options])")," might fail if the selector doesn't match any nodes during the given timeframe."),(0,o.kt)("p",null,"For certain types of errors Puppeteer uses specific error classes. These classes are available via ",(0,o.kt)("inlineCode",{parentName:"p"},"puppeteer.errors"),"."),(0,o.kt)("h2",{id:"example"},"Example"),(0,o.kt)("p",null,"An example of handling a timeout error:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-js"},"try {\n await page.waitForSelector('.foo');\n} catch (e) {\n if (e instanceof puppeteer.errors.TimeoutError) {\n // Do something if this is a timeout.\n }\n}\n\n")))}f.isMDXComponent=!0}}]);