microsoft/vscode-react-native

Public

mirrored fromhttps://github.com/microsoft/vscode-react-nativeAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
0.6.5

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/extension/appcenter/command/commandResult.ts

48lines · modecode

1// 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 {
7 succeeded: boolean;
8 result?: any;
9}
10
11export interface CommandFailedResult {
12 succeeded: boolean;
13 errorCode: number;
14 errorMessage: string;
15 exception?: Error;
16}
17
18export function success(res: any): CommandResult {
19 return {
20 succeeded: true,
21 result: res,
22 };
23 }
24
25// Used when there's a failure otherwise
26export function failure(errorCode: number, errorMessage: string): CommandResult {
27 return {
28 succeeded: false,
29 errorCode,
30 errorMessage,
31 };
32}
33
34export enum ErrorCodes {
35 Succeeded = 0,
36 // Command given contained illegal characters/names
37 IllegalCommand,
38 // Command was legal, but not found
39 NoSuchCommand,
40 // Unhandled exception occurred
41 Exception,
42 // A parameter is invalid
43 InvalidParameter,
44 // Command requires logged in user
45 NotLoggedIn,
46 // The requested resource was not found
47 NotFound,
48 }