2019-11-18 18:18:28 -08:00
|
|
|
/**
|
|
|
|
* Copyright 2018 Google Inc. All rights reserved.
|
|
|
|
* Modifications copyright (c) Microsoft Corporation.
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
class CustomError extends Error {
|
|
|
|
constructor(message: string) {
|
|
|
|
super(message);
|
|
|
|
this.name = this.constructor.name;
|
|
|
|
Error.captureStackTrace(this, this.constructor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export class TimeoutError extends CustomError {}
|
2020-09-30 21:17:30 -07:00
|
|
|
|
2023-10-12 11:05:34 -07:00
|
|
|
export class TargetClosedError extends Error {
|
2023-10-17 15:35:41 -07:00
|
|
|
constructor(cause?: string, logs?: string) {
|
|
|
|
super((cause || 'Target page, context or browser has been closed') + (logs || ''));
|
2023-10-12 11:05:34 -07:00
|
|
|
this.name = this.constructor.name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function isTargetClosedError(error: Error) {
|
2023-10-17 15:35:41 -07:00
|
|
|
return error instanceof TargetClosedError || error.name === 'TargetClosedError';
|
2020-09-30 21:17:30 -07:00
|
|
|
}
|