microsoft/vscode-react-native

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
e45838cbf8bb84beab7d36042bcdbc57fe0319c8

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/common/error/internalError.ts

45lines · modeblame

17161993Meena Kunnathur Balakrishnan10 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
190e393cMeena Kunnathur Balakrishnan10 years ago4export enum InternalErrorLevel {
5Error,
6Warning
7}
8
17161993Meena Kunnathur Balakrishnan10 years ago9export class InternalError extends Error {
10public errorCode: number;
190e393cMeena Kunnathur Balakrishnan10 years ago11public errorLevel: InternalErrorLevel;
12
13public get isInternalError(): boolean {
14return true;
15}
17161993Meena Kunnathur Balakrishnan10 years ago16
190e393cMeena Kunnathur Balakrishnan10 years ago17constructor(errorCode: number, message: string, errorLevel: InternalErrorLevel = InternalErrorLevel.Error) {
17161993Meena Kunnathur Balakrishnan10 years ago18super(message);
19this.errorCode = errorCode;
190e393cMeena Kunnathur Balakrishnan10 years ago20this.errorLevel = errorLevel;
17161993Meena Kunnathur Balakrishnan10 years ago21this.message = message;
22}
23}
24
25export class NestedError extends InternalError {
26public innerError: Error | any; // Normally this should be an error, but we support any value
898cb3c6Meena Kunnathur Balakrishnan10 years ago27private _extras: any;
17161993Meena Kunnathur Balakrishnan10 years ago28
898cb3c6Meena Kunnathur Balakrishnan10 years ago29constructor(errorCode: number, message: string, innerError: any = null, extras?: any, errorLevel: InternalErrorLevel = InternalErrorLevel.Error) {
a4a7e387Meena Kunnathur Balakrishnan10 years ago30super(errorCode, message, errorLevel);
17161993Meena Kunnathur Balakrishnan10 years ago31this.innerError = innerError;
32this.name = innerError ? innerError.name : null;
33const innerMessage = innerError ? innerError.message : null;
34this.message = innerMessage ? `${message}: ${innerMessage}` : message;
898cb3c6Meena Kunnathur Balakrishnan10 years ago35this._extras = extras;
36}
37
38public get extras(): any {
39return this._extras;
17161993Meena Kunnathur Balakrishnan10 years ago40}
190e393cMeena Kunnathur Balakrishnan10 years ago41
42public static getWrappedError(error: InternalError, innerError: any): NestedError {
2166bdabdigeff10 years ago43return new NestedError(innerError.errorCode || error.errorCode, error.message, innerError);
190e393cMeena Kunnathur Balakrishnan10 years ago44}
17161993Meena Kunnathur Balakrishnan10 years ago45}