Skip to content

Commit

Permalink
Merge pull request #20350 from emberjs/no-ember-error-beta
Browse files Browse the repository at this point in the history
  • Loading branch information
wagenet committed Jan 12, 2023
2 parents 4e64f71 + 1114a2e commit 3c39d7e
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 26 deletions.
3 changes: 1 addition & 2 deletions packages/@ember/-internals/metal/lib/alias.ts
Expand Up @@ -2,7 +2,6 @@ import type { Meta } from '@ember/-internals/meta';
import { meta as metaFor } from '@ember/-internals/meta';
import { inspect } from '@ember/-internals/utils';
import { assert } from '@ember/debug';
import EmberError from '@ember/error';
import type { UpdatableTag } from '@glimmer/validator';
import {
consumeTag,
Expand Down Expand Up @@ -115,7 +114,7 @@ export class AliasedProperty extends ComputedDescriptor {
}

function AliasedProperty_readOnlySet(obj: object, keyName: string): never {
throw new EmberError(`Cannot set read-only property '${keyName}' on object: ${inspect(obj)}`);
throw new Error(`Cannot set read-only property '${keyName}' on object: ${inspect(obj)}`);
}

function AliasedProperty_oneWaySet(obj: object, keyName: string, value: any): any {
Expand Down
3 changes: 1 addition & 2 deletions packages/@ember/-internals/metal/lib/computed.ts
Expand Up @@ -2,7 +2,6 @@ import type { Meta } from '@ember/-internals/meta';
import { meta as metaFor } from '@ember/-internals/meta';
import { inspect, toString } from '@ember/-internals/utils';
import { assert } from '@ember/debug';
import EmberError from '@ember/error';
import { isDestroyed } from '@glimmer/destroyable';
import { DEBUG } from '@glimmer/env';
import type { UpdatableTag } from '@glimmer/validator';
Expand Down Expand Up @@ -513,7 +512,7 @@ export class ComputedProperty extends ComputedDescriptor {
}

_throwReadOnlyError(obj: object, keyName: string): never {
throw new EmberError(`Cannot set read-only property "${keyName}" on object: ${inspect(obj)}`);
throw new Error(`Cannot set read-only property "${keyName}" on object: ${inspect(obj)}`);
}

_set(obj: object, keyName: string, value: unknown, meta: Meta): unknown {
Expand Down
5 changes: 1 addition & 4 deletions packages/@ember/-internals/metal/lib/property_set.ts
@@ -1,6 +1,5 @@
import { lookupDescriptor, setWithMandatorySetter, toString } from '@ember/-internals/utils';
import { assert } from '@ember/debug';
import EmberError from '@ember/error';
import { DEBUG } from '@glimmer/env';
import { COMPUTED_SETTERS } from './decorator';
import { isPath } from './path_cache';
Expand Down Expand Up @@ -115,9 +114,7 @@ function _setPath(root: object, path: string, value: any, tolerant?: boolean): a
if (newRoot !== null && newRoot !== undefined) {
return set(newRoot, keyName, value);
} else if (!tolerant) {
throw new EmberError(
`Property set failed: object in path "${parts.join('.')}" could not be found.`
);
throw new Error(`Property set failed: object in path "${parts.join('.')}" could not be found.`);
}
}

Expand Down
3 changes: 1 addition & 2 deletions packages/@ember/-internals/views/lib/views/states/default.ts
@@ -1,10 +1,9 @@
import EmberError from '@ember/error';
import type { ViewState } from '../states';

const _default: ViewState = {
// appendChild is only legal while rendering the buffer.
appendChild() {
throw new EmberError("You can't use appendChild outside of the rendering process");
throw new Error("You can't use appendChild outside of the rendering process");
},

// Handle events from `Ember.EventDispatcher`
Expand Down
@@ -1,16 +1,15 @@
import EmberError from '@ember/error';
import type { ViewState } from '../states';
import _default from './default';

const destroying: ViewState = {
..._default,

appendChild() {
throw new EmberError("You can't call appendChild on a view being destroyed");
throw new Error("You can't call appendChild on a view being destroyed");
},

rerender() {
throw new EmberError("You can't call rerender on a view being destroyed");
throw new Error("You can't call rerender on a view being destroyed");
},
};

Expand Down
3 changes: 1 addition & 2 deletions packages/@ember/-internals/views/lib/views/states/in_dom.ts
@@ -1,7 +1,6 @@
import { teardownMandatorySetter } from '@ember/-internals/utils';
import type Component from '@ember/component';
import { assert } from '@ember/debug';
import EmberError from '@ember/error';
import { DEBUG } from '@glimmer/env';
import type { ViewState } from '../states';
import hasElement from './has_element';
Expand Down Expand Up @@ -32,7 +31,7 @@ const inDOM: ViewState = {
},
set(value) {
if (value !== elementId) {
throw new EmberError("Changing a view's elementId after creation is not allowed");
throw new Error("Changing a view's elementId after creation is not allowed");
}
},
});
Expand Down
3 changes: 1 addition & 2 deletions packages/@ember/debug/index.ts
@@ -1,6 +1,5 @@
import { isChrome, isFirefox } from '@ember/-internals/browser-environment';
import type { AnyFn } from '@ember/-internals/utils/types';
import EmberError from '@ember/error';
import { DEBUG } from '@glimmer/env';
import type { DeprecateFunc, DeprecationOptions } from './lib/deprecate';
import _deprecate from './lib/deprecate';
Expand Down Expand Up @@ -169,7 +168,7 @@ if (DEBUG) {
*/
setDebugFunction('assert', function assert(desc, test) {
if (!test) {
throw new EmberError(`Assertion Failed: ${desc}`);
throw new Error(`Assertion Failed: ${desc}`);
}
});

Expand Down
3 changes: 1 addition & 2 deletions packages/@ember/engine/instance.ts
Expand Up @@ -5,7 +5,6 @@
import EmberObject from '@ember/object';
import { RSVP } from '@ember/-internals/runtime';
import { assert } from '@ember/debug';
import EmberError from '@ember/error';
import { Registry, privatize as P } from '@ember/-internals/container';
import { guidFor } from '@ember/-internals/utils';
import { ENGINE_PARENT, getEngineParent, setEngineParent } from './lib/engine-parent';
Expand Down Expand Up @@ -203,7 +202,7 @@ class EngineInstance extends EmberObject.extend(RegistryProxyMixin, ContainerPro
let Engine = this.lookup(`engine:${name}`);

if (!Engine) {
throw new EmberError(
throw new Error(
`You attempted to mount the engine '${name}', but it is not registered with its parent.`
);
}
Expand Down
3 changes: 1 addition & 2 deletions packages/@ember/object/promise-proxy-mixin.ts
@@ -1,7 +1,6 @@
import { get, setProperties, computed } from '@ember/object';
import Mixin from '@ember/object/mixin';
import type { AnyFn, MethodNamesOf } from '@ember/-internals/utils/types';
import EmberError from '@ember/error';
import type RSVP from 'rsvp';
import type CoreObject from '@ember/object/core';

Expand Down Expand Up @@ -227,7 +226,7 @@ const PromiseProxyMixin = Mixin.create({

promise: computed({
get() {
throw new EmberError("PromiseProxy's promise must be set");
throw new Error("PromiseProxy's promise must be set");
},
set(_key, promise: RSVP.Promise<unknown>) {
return tap(this, promise);
Expand Down
3 changes: 1 addition & 2 deletions packages/@ember/routing/lib/utils.ts
Expand Up @@ -3,7 +3,6 @@ import { getOwner } from '@ember/-internals/owner';
import type { ControllerQueryParam, ControllerQueryParamType } from '@ember/controller';
import { assert, deprecate } from '@ember/debug';
import EngineInstance from '@ember/engine/instance';
import EmberError from '@ember/error';
import type { InternalRouteInfo, ModelFor } from 'router_js';
import type Router from 'router_js';
import { STATE_SYMBOL } from 'router_js';
Expand Down Expand Up @@ -252,7 +251,7 @@ export function prefixRouteNameArg<T extends NamedRouteArgs<Route> | UnnamedRout
if (owner.routable && typeof args[0] === 'string') {
routeName = args[0];
if (resemblesURL(routeName)) {
throw new EmberError(
throw new Error(
'Programmatic transitions by URL cannot be used within an Engine. Please use the route name instead.'
);
} else {
Expand Down
5 changes: 2 additions & 3 deletions packages/@ember/routing/router.ts
Expand Up @@ -23,7 +23,6 @@ import { A as emberA } from '@ember/array';
import { typeOf } from '@ember/utils';
import Evented from '@ember/object/evented';
import { assert, deprecate, info } from '@ember/debug';
import EmberError from '@ember/error';
import { cancel, once, run, scheduleOnce } from '@ember/runloop';
import { DEBUG } from '@glimmer/env';
import type { QueryParamMeta, RenderOptions } from '@ember/routing/route';
Expand Down Expand Up @@ -1757,7 +1756,7 @@ export function triggerEvent<
return;
}
// TODO: update?
throw new EmberError(
throw new Error(
`Can't trigger action '${name}' because your app hasn't finished transitioning into its first route. To trigger an action on destination routes during a transition, you can call \`.send()\` on the \`Transition\` object passed to the \`model/beforeModel/afterModel\` hooks.`
);
}
Expand Down Expand Up @@ -1791,7 +1790,7 @@ export function triggerEvent<
}

if (!eventWasHandled && !ignoreFailure) {
throw new EmberError(
throw new Error(
`Nothing handled the action '${name}'. If you did handle the action, this error can be caused by returning true from an action handler in a controller, causing the action to bubble.`
);
}
Expand Down

0 comments on commit 3c39d7e

Please sign in to comment.