Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Update ember-cli-babel to v7.x and use native Error instead of EmberError #433

Merged
merged 4 commits into from
Mar 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,10 @@ export default function someOtherUtility(url) {

This information is only relevant if you're looking to contribute to `ember-ajax`.

### Compatibility

- Ember CLI v2.13 or above

### Installation

- `git clone` this repository
Expand Down
4 changes: 1 addition & 3 deletions addon/errors.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import EmberError from '@ember/error';

export class AjaxError extends EmberError {
export class AjaxError extends Error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be a bit more verbose here: Ember 3.8 changed EmberError to no longer be an Error subclass, but instead reexport Error. Babel 6 can't deal with extending native classes, but Babel 7 can. Babel 7 does not detect that it needs to do that though because of the reexport.

Since the bump to ember-cli-babel@7 and the corresponding change in the minimum Ember CLI requirements require a major version bump anyway it seems fine to change the base class here to a regular Error too.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you just solved why we couldn't figure out subclassing with that change properly in ember-data (not detecting the native class due to re-export)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

happy to help 😉

payload: any;
status: number;

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
]
},
"dependencies": {
"ember-cli-babel": "^6.16.0",
"ember-cli-babel": "^7.5.0",
"najax": "^1.0.3"
},
"devDependencies": {
Expand Down
2 changes: 0 additions & 2 deletions tests/unit/errors-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import EmberError from '@ember/error';
import { describe, it } from 'mocha';
import { assert } from 'chai';

Expand Down Expand Up @@ -34,7 +33,6 @@ describe('unit/errors-test - AjaxError', function() {
it('AjaxError', function() {
const error = new AjaxError();
ok(error instanceof Error);
ok(error instanceof EmberError);
});

it('InvalidError', function() {
Expand Down