mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
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:
@@ -14,7 +14,25 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const PROJECT_ROOT = fs.existsSync(path.join(__dirname, '..', 'package.json')) ? path.join(__dirname, '..') : path.join(__dirname, '..', '..');
|
||||
|
||||
const utils = module.exports = {
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
projectRoot: function() {
|
||||
return PROJECT_ROOT;
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {*}
|
||||
*/
|
||||
requireRoot: function(name) {
|
||||
return require(path.join(PROJECT_ROOT, name));
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {!Page} page
|
||||
* @param {string} frameId
|
||||
|
||||
Reference in New Issue
Block a user