Skip to content

Commit

Permalink
Swap custom errors for Ember assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlafroscia committed Mar 31, 2018
1 parent 9b2838b commit a1af4df
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 49 deletions.
34 changes: 0 additions & 34 deletions addon/-private/errors.js

This file was deleted.

10 changes: 3 additions & 7 deletions addon/components/step-manager.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import Component from '@ember/component';
import { set, get } from '@ember/object';
import { isEmpty } from '@ember/utils';
import { assert } from '@ember/debug';
import hbs from 'htmlbars-inline-precompile';
import StateMachine from 'ember-steps/-private/state-machine';
import { MissingPropertyError } from 'ember-steps/-private/errors';

const layout = hbs`
{{yield (hash
Expand Down Expand Up @@ -57,16 +57,12 @@ export default Component.extend({

// Set up the state machine
const initialStep = get(this, 'currentStep');
if (!initialStep) {
throw new MissingPropertyError('currentStep');
}
assert('Missing `initialStep` property', !!initialStep);

this._lastStep = initialStep;

const stepCount = get(this, 'stepCount');
if (!stepCount) {
throw new MissingPropertyError('stepCount');
}
assert('Missing `stepCount` property', !!stepCount);

set(
this,
Expand Down
10 changes: 2 additions & 8 deletions addon/components/step-manager/step.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import Component from '@ember/component';
import { computed, get, observer } from '@ember/object';
import { isBlank } from '@ember/utils';
import { assert } from '@ember/debug';
import hbs from 'htmlbars-inline-precompile';
import { StepNameError } from 'ember-steps/-private/errors';

export default Component.extend({
tagName: '',
Expand All @@ -19,12 +17,8 @@ export default Component.extend({
this._super(...arguments);

const name = get(this, 'name');
if (isBlank(name)) {
throw new StepNameError('Name must be provided');
}
if (typeof name !== 'string') {
throw new StepNameError('Name must be an immutable string');
}
assert('Step must have a name present', !!name);
assert('Step must be a `string`', typeof name === 'string');

this['register-step'](this);
},
Expand Down

0 comments on commit a1af4df

Please sign in to comment.