Skip to content

Instantly share code, notes, and snippets.

@mydea
Last active April 15, 2019 12:52
Show Gist options
  • Save mydea/66f7c0a1ada2a07c2ade10b84c425037 to your computer and use it in GitHub Desktop.
Save mydea/66f7c0a1ada2a07c2ade10b84c425037 to your computer and use it in GitHub Desktop.
EmberError vs. native Error
import Ember from 'ember';
import EmberError from '@ember/error';
const NativeError = Error;
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
emberError: Ember.computed(function() {
return new AdapterError('test');
}),
nativeError: Ember.computed(function() {
return new NativeAdapterError('test');
})
});
function AdapterError(errors, message = 'Adapter operation failed') {
this.isAdapterError = true;
EmberError.call(this, message);
this.errors = errors || [
{
title: 'Adapter Error',
detail: message,
},
];
}
AdapterError.prototype = Object.create(EmberError.prototype);
// Native Error
function NativeAdapterError(errors, message = 'Adapter operation failed') {
this.isAdapterError = true;
NativeError.call(this, message);
this.errors = errors || [
{
title: 'Adapter Error',
detail: message,
},
];
}
NativeAdapterError.prototype = Object.create(NativeError.prototype);
<div>
@ember/error: {{emberError}}
</div>
<div>
Error: {{nativeError}}
</div>
{
"version": "0.15.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js",
"ember": "3.4.3",
"ember-template-compiler": "3.4.3",
"ember-testing": "3.4.3"
},
"addons": {
"ember-data": "3.4.2"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment