2019-11-19 03:18:28 +01: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-10-01 06:17:30 +02:00
|
|
|
|
2023-10-12 20:05:34 +02:00
|
|
|
export class TargetClosedError extends Error {
|
2023-10-18 00:35:41 +02:00
|
|
|
constructor(cause?: string, logs?: string) {
|
|
|
|
|
super((cause || 'Target page, context or browser has been closed') + (logs || ''));
|
2023-10-12 20:05:34 +02:00
|
|
|
this.name = this.constructor.name;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function isTargetClosedError(error: Error) {
|
2023-10-18 00:35:41 +02:00
|
|
|
return error instanceof TargetClosedError || error.name === 'TargetClosedError';
|
2020-10-01 06:17:30 +02:00
|
|
|
}
|