Skip to content

Commit

Permalink
v3.22.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rjrodger committed Jul 2, 2020
1 parent 4feef9c commit 6a2f6bc
Show file tree
Hide file tree
Showing 8 changed files with 2,649 additions and 2,429 deletions.
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 3.22.0 2020-07-02

* Update patrun module to fix sub multiple fires
* PR #855 seneca.fail - allow the boolean first arg to trigger the error throw


## 3.21.2 2020-05-26

* Handle 'object' === typeof(null) edge cases.
Expand Down
4 changes: 1 addition & 3 deletions lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,7 @@ exports.fail = function (...args) {
return failIf(this, ...args)
}

throw this.util.error('fail_wrong_number_of_args',
{ num_args: args.length })

throw this.util.error('fail_wrong_number_of_args', { num_args: args.length })

function failIf(self, cond, code, args) {
if (typeof cond !== 'boolean') {
Expand Down
237 changes: 115 additions & 122 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "seneca",
"description": "A Microservices Framework for Node.js",
"version": "3.21.2",
"version": "3.22.0",
"license": "MIT",
"homepage": "http://senecajs.org",
"keywords": [
Expand Down
37 changes: 31 additions & 6 deletions test/api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ describe('api', function () {
} catch (err) {
expect(err.code).equal('test_args')
expect(err.message).equal('seneca: Test args foo { bar: 1 }.')
expect(err.details).equal({ arg0: 'foo', arg1: { bar: 1 }, not_an_arg: 1 })
expect(err.details).equal({
arg0: 'foo',
arg1: { bar: 1 },
not_an_arg: 1,
})
expect(err.seneca).true()

return fin()
Expand All @@ -70,11 +74,19 @@ describe('api', function () {
describe('when the condition is true', function () {
it('throws', function (fin) {
try {
si.fail(true, 'test_args', { arg0: 'foo', arg1: { bar: 1 }, not_an_arg: 1 })
si.fail(true, 'test_args', {
arg0: 'foo',
arg1: { bar: 1 },
not_an_arg: 1,
})
} catch (err) {
expect(err.code).equal('test_args')
expect(err.message).equal('seneca: Test args foo { bar: 1 }.')
expect(err.details).equal({ arg0: 'foo', arg1: { bar: 1 }, not_an_arg: 1 })
expect(err.details).equal({
arg0: 'foo',
arg1: { bar: 1 },
not_an_arg: 1,
})
expect(err.seneca).true()

return fin()
Expand All @@ -87,7 +99,11 @@ describe('api', function () {
describe('when the condition is false', function () {
it('does not throw', function (fin) {
try {
si.fail(false, 'test_args', { arg0: 'foo', arg1: { bar: 1 }, not_an_arg: 1 })
si.fail(false, 'test_args', {
arg0: 'foo',
arg1: { bar: 1 },
not_an_arg: 1,
})
} catch (err) {
return fin(new Error('Expected the "fail" method to not throw.'))
}
Expand All @@ -99,7 +115,11 @@ describe('api', function () {
describe('when the condition is not a boolean', function () {
it('throws informing the client of the wrong type', function (fin) {
try {
si.fail(0, 'test_args', { arg0: 'foo', arg1: { bar: 1 }, not_an_arg: 1 })
si.fail(0, 'test_args', {
arg0: 'foo',
arg1: { bar: 1 },
not_an_arg: 1,
})
} catch (err) {
expect(err.code).equal('fail_cond_must_be_bool')

Expand Down Expand Up @@ -140,7 +160,12 @@ describe('api', function () {
describe('when given too many arguments', () => {
it('throws a seneca error', function (fin) {
try {
si.fail(true, 'test_args', { arg0: 'foo', arg1: { bar: 1 }, not_an_arg: 1 }, 2)
si.fail(
true,
'test_args',
{ arg0: 'foo', arg1: { bar: 1 }, not_an_arg: 1 },
2
)
} catch (err) {
expect(err.code).equal('fail_wrong_number_of_args')

Expand Down
Loading

0 comments on commit 6a2f6bc

Please sign in to comment.