feat: introduce puppeteer/Errors (#3056)

This patch adds a new require, `puppeteer/Errors`, that
holds all the Puppeteer-specific error classes.

Currently, the only custom error class we use is `TimeoutError`. We'll
expand in future with `CrashError` and some others.

Fixes #1694.
This commit is contained in:
Andrey Lushnikov
2018-08-09 16:51:12 -07:00
committed by GitHub
parent 231a2be971
commit 204c7ec8c4
21 changed files with 178 additions and 38 deletions

View File

@@ -22,6 +22,7 @@ const Message = require('../Message');
const EXCLUDE_CLASSES = new Set([
'CSSCoverage',
'Connection',
'CustomError',
'EmulationManager',
'FrameManager',
'JSCoverage',
@@ -35,11 +36,12 @@ const EXCLUDE_CLASSES = new Set([
'WaitTask',
]);
const EXCLUDE_METHODS = new Set([
const EXCLUDE_PROPERTIES = new Set([
'Browser.create',
'Headers.fromPayload',
'Page.create',
'JSHandle.toString',
'TimeoutError.name',
]);
/**
@@ -137,7 +139,7 @@ function filterJSDocumentation(jsDocumentation) {
// Exclude all constructors by default.
if (member.name === 'constructor' && member.type === 'method')
return false;
return !EXCLUDE_METHODS.has(`${cls.name}.${member.name}`);
return !EXCLUDE_PROPERTIES.has(`${cls.name}.${member.name}`);
});
classes.push(new Documentation.Class(cls.name, members));
}