/** * Copyright (c) 2020-present, Goldman Sachs * * 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. */ import type { SuperGenericFunction } from './CommonUtils'; export declare abstract class ApplicationError extends Error { message: string; } export declare class EnrichedError extends Error { constructor(name: string, error: string | Error | undefined, overideMessage?: string); } export declare class IllegalStateError extends EnrichedError { constructor(error?: Error | string); } export declare class UnsupportedOperationError extends EnrichedError { constructor(message?: string, unsupportedObject?: unknown); } /** * This is a relatively crude way to handle error of type unknown thrown for now. * We should revisit this when Typescript supports `throws` clause * See https://github.com/microsoft/TypeScript/issues/13219 * * NOTE: There's a problem with this check in JSDOM leading so we have to disable this in test environment * JSDOM uses their own isolated object rather than native object for performance purpose * See https://github.com/jsdom/jsdom/issues/3082 * For example, TypeErrors generated by `webidl2js` or `whatwg-url` used by `jsdom`, or manually-thrown ones inside impl classes, * are thrown using global.TypeError, not dom.window.TypeError. This change is hard to implement as of now * See https://github.com/jsdom/jsdom/issues/2727 * Read more related discussions at: * https://github.com/jsdom/jsdom/issues/1737 * https://github.com/webcomponents/polyfills/issues/105 * https://github.com/jsdom/jsdom/issues/1769 * https://github.com/jsdom/jsdom/issues/2555 */ export declare function assertErrorThrown(error: unknown): asserts error is Error; export declare const returnUndefOnError: (fn: T) => ReturnType | undefined; export declare const decorateErrorMessageIfExists: (fn: T, errorMessageDecorator: (msg: string) => string) => ReturnType; //# sourceMappingURL=ErrorUtils.d.ts.map