mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-02 09:35:40 -05:00
29 lines
954 B
TypeScript
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;
|
|
}
|