Files
azuredatastudio/src/vs/base/common/errorsWithActions.ts
2019-02-21 17:56:04 -08:00

29 lines
954 B
TypeScript

/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { IAction } from 'vs/base/common/actions';
export interface IErrorOptions {
actions?: IAction[];
}
export interface IErrorWithActions {
actions?: IAction[];
}
export function isErrorWithActions(obj: any): obj is IErrorWithActions {
return obj instanceof Error && Array.isArray((obj as IErrorWithActions).actions);
}
export function createErrorWithActions(message: string, options: IErrorOptions = Object.create(null)): Error & IErrorWithActions {
const result = new Error(message);
if (options.actions) {
(<IErrorWithActions>result).actions = options.actions;
}
return result;
}