diff --git a/src/internal/operators/elementAt.ts b/src/internal/operators/elementAt.ts index 8c77f4d320..c50d5ff4b7 100644 --- a/src/internal/operators/elementAt.ts +++ b/src/internal/operators/elementAt.ts @@ -1,14 +1,10 @@ -<<<<<<< HEAD -import { ArgumentOutOfRangeError } from '../util/ArgumentOutOfRangeError'; -======= import { createOutOfRangeError } from '../util/ArgumentOutOfRangeError'; ->>>>>>> refactor(ArgumentOutOfRangeError): is now deprecated import { Observable } from '../Observable'; import { MonoTypeOperatorFunction } from '../types'; import { filter } from './filter'; import { throwIfEmpty } from './throwIfEmpty'; import { defaultIfEmpty } from './defaultIfEmpty'; -import { take } from './take'; +import { take } from './take';s /** * Emits the single value at the specified `index` in a sequence of emissions diff --git a/src/internal/operators/last.ts b/src/internal/operators/last.ts index 2dc2fdacfa..0e2698baaf 100644 --- a/src/internal/operators/last.ts +++ b/src/internal/operators/last.ts @@ -1,9 +1,5 @@ import { Observable } from '../Observable'; -<<<<<<< HEAD -import { EmptyError } from '../util/EmptyError'; -======= import { createEmptyError } from '../util/EmptyError'; ->>>>>>> refactor(EmptyError): is deprecated import { OperatorFunction } from '../../internal/types'; import { filter } from './filter'; import { takeLast } from './takeLast'; diff --git a/src/internal/util/ArgumentOutOfRangeError.ts b/src/internal/util/ArgumentOutOfRangeError.ts index 46fc424bd9..23f668e72e 100644 --- a/src/internal/util/ArgumentOutOfRangeError.ts +++ b/src/internal/util/ArgumentOutOfRangeError.ts @@ -33,5 +33,5 @@ ArgumentOutOfRangeErrorImpl.prototype = Object.create(Error.prototype); export const ArgumentOutOfRangeError: ArgumentOutOfRangeErrorCtor = ArgumentOutOfRangeErrorImpl as any; export function createOutOfRangeError() { - return createRxError('out of range', RxErrorCode.OutOfRangeError, ArgumentOutOfRangeError); + return createRxError('out of range', RxErrorCode.OutOfRange, ArgumentOutOfRangeError); } diff --git a/src/internal/util/ObjectUnsubscribedError.ts b/src/internal/util/ObjectUnsubscribedError.ts index 6ea14a6543..4fb1b03d87 100644 --- a/src/internal/util/ObjectUnsubscribedError.ts +++ b/src/internal/util/ObjectUnsubscribedError.ts @@ -32,5 +32,5 @@ ObjectUnsubscribedErrorImpl.prototype = Object.create(Error.prototype); export const ObjectUnsubscribedError: ObjectUnsubscribedErrorCtor = ObjectUnsubscribedErrorImpl as any; export function createObjectUnsubscribedError() { - return createRxError('object unsubscribed', RxErrorCode.ObjectUnsubscribedError, ObjectUnsubscribedError); + return createRxError('object unsubscribed', RxErrorCode.ObjectUnsubscribed, ObjectUnsubscribedError); } diff --git a/src/internal/util/TimeoutError.ts b/src/internal/util/TimeoutError.ts index e830bdfa68..b9e403ef0f 100644 --- a/src/internal/util/TimeoutError.ts +++ b/src/internal/util/TimeoutError.ts @@ -30,5 +30,5 @@ TimeoutErrorImpl.prototype = Object.create(Error.prototype); export const TimeoutError: TimeoutErrorCtor = TimeoutErrorImpl as any; export function createTimeoutError() { - return createRxError('observable timed out', RxErrorCode.TimeoutError, TimeoutError); + return createRxError('observable timed out', RxErrorCode.Timeout, TimeoutError); } diff --git a/src/internal/util/UnsubscriptionError.ts b/src/internal/util/UnsubscriptionError.ts index 7f808116b0..96e4353a9d 100644 --- a/src/internal/util/UnsubscriptionError.ts +++ b/src/internal/util/UnsubscriptionError.ts @@ -34,6 +34,6 @@ export const UnsubscriptionError: UnsubscriptionErrorCtor = UnsubscriptionErrorI export function createTeardownError(errors: any[]) { const error: any = new UnsubscriptionError(errors); - error.__rxjsErrorCode = RxErrorCode.TeardownError; + error.__rxjsErrorCode = RxErrorCode.Teardown; return error; } diff --git a/src/internal/util/errors.ts b/src/internal/util/errors.ts index 1ec36a63a8..96d8f7a1b0 100644 --- a/src/internal/util/errors.ts +++ b/src/internal/util/errors.ts @@ -1,12 +1,18 @@ +/** + * Used to identify different types of RxJS errors. + */ export const enum RxErrorCode { Empty = 0, - OutOfRangeError = 1, - ObjectUnsubscribedError = 2, - TimeoutError = 3, - TeardownError = 4, + OutOfRange = 1, + ObjectUnsubscribed = 2, + Timeout = 3, + Teardown = 4, } +/** + * Creates an error and decorates it with the appropriate error code for identification later. + */ export function createRxError(message: string, code: RxErrorCode, ErrorType: any = Error) { const result = new ErrorType('RxJS: ' + message); (result as any).__rxjsErrorCode = code; @@ -33,7 +39,7 @@ export function isEmptyError(err: any) { * was out of range. */ export function isOutOfRangeError(err: any) { - return err.__rxjsErrorCode === RxErrorCode.OutOfRangeError; + return err.__rxjsErrorCode === RxErrorCode.OutOfRange; } /** @@ -41,7 +47,7 @@ export function isOutOfRangeError(err: any) { * was unsubscribed, and an action was taken on it. */ export function isObjectUnsubscribedError(err: any) { - return err.__rxjsErrorCode === RxErrorCode.ObjectUnsubscribedError; + return err.__rxjsErrorCode === RxErrorCode.ObjectUnsubscribed; } /** @@ -49,7 +55,7 @@ export function isObjectUnsubscribedError(err: any) { * times out, for example with the {@link timeout} operator. */ export function isTimeoutError(err: any) { - return err.__rxjsErrorCode === RxErrorCode.TimeoutError; + return err.__rxjsErrorCode === RxErrorCode.Timeout; } /** @@ -58,5 +64,5 @@ export function isTimeoutError(err: any) { * chain. */ export function isTeardownError(err: any) { - return err.__rxjsErrorCode === RxErrorCode.TeardownError; + return err.__rxjsErrorCode === RxErrorCode.Teardown; }