@kravc/dos 1.4.7 → 1.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/Operation.js +12 -0
- package/src/Service.spec.js +18 -7
- package/src/errors/UnprocessibleConditionError.js +11 -0
- package/src/errors/index.js +2 -1
package/package.json
CHANGED
package/src/Operation.js
CHANGED
|
@@ -58,6 +58,12 @@ class Operation {
|
|
|
58
58
|
description: 'Invalid operation input, make sure operation parameters' +
|
|
59
59
|
' do match specification'
|
|
60
60
|
}
|
|
61
|
+
|
|
62
|
+
errors.InvalidParametersError = {
|
|
63
|
+
statusCode: 400,
|
|
64
|
+
description: 'Invalid operation parameters, input syntax is correct,' +
|
|
65
|
+
' but input values are not processible'
|
|
66
|
+
}
|
|
61
67
|
}
|
|
62
68
|
|
|
63
69
|
if (this.outputSchema) {
|
|
@@ -68,6 +74,12 @@ class Operation {
|
|
|
68
74
|
}
|
|
69
75
|
}
|
|
70
76
|
|
|
77
|
+
errors.UnprocessibleConditionError = {
|
|
78
|
+
statusCode: 422,
|
|
79
|
+
description: 'Operation failed to process the request cause of expected' +
|
|
80
|
+
' exit condition'
|
|
81
|
+
}
|
|
82
|
+
|
|
71
83
|
return errors
|
|
72
84
|
}
|
|
73
85
|
|
package/src/Service.spec.js
CHANGED
|
@@ -115,6 +115,21 @@ describe('Service', () => {
|
|
|
115
115
|
expect(response.result.error.code).to.eql('InvalidInputError')
|
|
116
116
|
})
|
|
117
117
|
|
|
118
|
+
it('returns "InvalidParametersError / 400" if invalid parameters', async () => {
|
|
119
|
+
class InvalidIndexProfiles extends IndexProfiles {
|
|
120
|
+
action() {
|
|
121
|
+
throw new errors.InvalidParametersError()
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const modules = [ InvalidIndexProfiles ]
|
|
126
|
+
const service = new Service(modules)
|
|
127
|
+
const response = await test.execute(service)('InvalidIndexProfiles')
|
|
128
|
+
|
|
129
|
+
expect(response.statusCode).to.eql(400)
|
|
130
|
+
expect(response.result.error.code).to.eql('InvalidParametersError')
|
|
131
|
+
})
|
|
132
|
+
|
|
118
133
|
it('returns "OperationNotFoundError / 404" if operation not found', async () => {
|
|
119
134
|
const response = await exec('DestroyProfile', {}, { authorization })
|
|
120
135
|
|
|
@@ -122,14 +137,10 @@ describe('Service', () => {
|
|
|
122
137
|
expect(response.result.error.code).to.eql('OperationNotFoundError')
|
|
123
138
|
})
|
|
124
139
|
|
|
125
|
-
it('returns "
|
|
140
|
+
it('returns "UnprocessibleConditionError / 422" if unprocessible condition', async () => {
|
|
126
141
|
class InvalidIndexProfiles extends IndexProfiles {
|
|
127
|
-
static get errors() {
|
|
128
|
-
return { ...super.errors, InvalidParametersError: { statusCode: 422 } }
|
|
129
|
-
}
|
|
130
|
-
|
|
131
142
|
action() {
|
|
132
|
-
throw new errors.
|
|
143
|
+
throw new errors.UnprocessibleConditionError()
|
|
133
144
|
}
|
|
134
145
|
}
|
|
135
146
|
|
|
@@ -138,7 +149,7 @@ describe('Service', () => {
|
|
|
138
149
|
const response = await test.execute(service)('InvalidIndexProfiles')
|
|
139
150
|
|
|
140
151
|
expect(response.statusCode).to.eql(422)
|
|
141
|
-
expect(response.result.error.code).to.eql('
|
|
152
|
+
expect(response.result.error.code).to.eql('UnprocessibleConditionError')
|
|
142
153
|
})
|
|
143
154
|
|
|
144
155
|
it('returns "InvalidOutputError / 500" if invalid output, logs an error', async () => {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const CommonError = require('./CommonError')
|
|
4
|
+
|
|
5
|
+
class UnprocessibleConditionError extends CommonError {
|
|
6
|
+
constructor(message = 'Invalid parameters') {
|
|
7
|
+
super('UnprocessibleConditionError', message)
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
module.exports = UnprocessibleConditionError
|
package/src/errors/index.js
CHANGED
|
@@ -6,5 +6,6 @@ module.exports = {
|
|
|
6
6
|
AccessDeniedError: require('./AccessDeniedError'),
|
|
7
7
|
DocumentExistsError: require('./DocumentExistsError'),
|
|
8
8
|
DocumentNotFoundError: require('./DocumentNotFoundError'),
|
|
9
|
-
InvalidParametersError: require('./InvalidParametersError')
|
|
9
|
+
InvalidParametersError: require('./InvalidParametersError'),
|
|
10
|
+
UnprocessibleConditionError: require('./UnprocessibleConditionError')
|
|
10
11
|
}
|