microsoft/vscode-react-native

Public

mirrored from https://github.com/microsoft/vscode-react-nativeAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
0.6.6

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

src/extension/appcenter/command/commandResult.ts

48lines · modeblame

bb45fbe6max-mironov8 years ago1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT license. See LICENSE file in the project root for details.
3
4export type CommandResult = CommandSucceededResult | CommandFailedResult;
5
6export interface CommandSucceededResult {
7succeeded: boolean;
86466695max-mironov8 years ago8result?: any;
bb45fbe6max-mironov8 years ago9}
10
11export interface CommandFailedResult {
12succeeded: boolean;
13errorCode: number;
14errorMessage: string;
15exception?: Error;
16}
86466695max-mironov8 years ago17
18export function success(res: any): CommandResult {
19return {
20succeeded: true,
21result: res,
22};
23}
24
25// Used when there's a failure otherwise
26export function failure(errorCode: number, errorMessage: string): CommandResult {
27return {
28succeeded: false,
29errorCode,
30errorMessage,
31};
32}
33
34export enum ErrorCodes {
35Succeeded = 0,
36// Command given contained illegal characters/names
37IllegalCommand,
38// Command was legal, but not found
39NoSuchCommand,
40// Unhandled exception occurred
41Exception,
42// A parameter is invalid
43InvalidParameter,
44// Command requires logged in user
45NotLoggedIn,
46// The requested resource was not found
47NotFound,
48}