light-service 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -4
- data/lib/light-service/context.rb +3 -7
- data/lib/light-service/version.rb +1 -1
- data/spec/context_spec.rb +4 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43b8226d18386ca933714af81639598fdff2332d
|
4
|
+
data.tar.gz: e7112eea09148ee8f06412e7e2f61cea18375d05
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c772140e17955b44a37b923ed4f09a110e5d21da479e2ba44c8a6b0f81b8f647808c722932b56b407bbee781bd57c33981cb36b403f24ee29f746e184410ad1
|
7
|
+
data.tar.gz: 741bf14615577c1d9fe518e5835e3a4a9bde8879810ce9765983db65195afbd5d63e598fe07335bbe47158a9779d9fe23e0f890560dc19bffe5e3bba3ba84784
|
data/README.md
CHANGED
@@ -202,8 +202,8 @@ Take a look at [this spec](spec/action_expects_and_promises_spec.rb) to see the
|
|
202
202
|
|
203
203
|
## Error Codes
|
204
204
|
|
205
|
-
You can
|
206
|
-
|
205
|
+
You can add some more structure to your error handling by taking advantage of error codes in the context.
|
206
|
+
Normally, when something goes wrong in your actions, you fail the process by setting the context to failure:
|
207
207
|
|
208
208
|
```ruby
|
209
209
|
class FooAction
|
@@ -216,8 +216,8 @@ end
|
|
216
216
|
```
|
217
217
|
|
218
218
|
However, you might need to handle the errors coming from your action pipeline differently.
|
219
|
-
Using an error code can help you check what type of expected error occurred
|
220
|
-
or
|
219
|
+
Using an error code can help you check what type of expected error occurred in the organizer
|
220
|
+
or in the actions.
|
221
221
|
|
222
222
|
```ruby
|
223
223
|
class FooAction
|
@@ -273,6 +273,8 @@ For further examples, please visit the project's [Wiki](https://github.com/adomo
|
|
273
273
|
Huge thanks to the [contributors](https://github.com/adomokos/light-service/graphs/contributors)!
|
274
274
|
|
275
275
|
## Release Notes
|
276
|
+
### 0.3.2
|
277
|
+
* Fixing documentation and using separate arguments instead of a hash when setting the context to failure
|
276
278
|
### 0.3.1
|
277
279
|
* Adding [error codes](https://github.com/adomokos/light-service#error-codes) to the context
|
278
280
|
|
@@ -60,13 +60,9 @@ module LightService
|
|
60
60
|
fail!(message)
|
61
61
|
end
|
62
62
|
|
63
|
-
def fail!(
|
64
|
-
|
65
|
-
|
66
|
-
@error_code = options[:error_code]
|
67
|
-
else
|
68
|
-
@message = options
|
69
|
-
end
|
63
|
+
def fail!(message=nil, error_code=nil)
|
64
|
+
@message = message
|
65
|
+
@error_code = error_code
|
70
66
|
@outcome = ::LightService::Outcomes::FAILURE
|
71
67
|
end
|
72
68
|
|
data/spec/context_spec.rb
CHANGED
@@ -84,17 +84,19 @@ module LightService
|
|
84
84
|
|
85
85
|
it "can be pushed into a FAILURE state with a message in an options hash" do
|
86
86
|
context = Context.make
|
87
|
-
context.fail!(
|
87
|
+
context.fail!("a sad end")
|
88
88
|
|
89
89
|
expect(context).to be_failure
|
90
|
+
expect(context.message).to eq("a sad end")
|
90
91
|
expect(context.error_code).to be_nil
|
91
92
|
end
|
92
93
|
|
93
94
|
it "can be pushed into a FAILURE state with an error code in an options hash" do
|
94
95
|
context = Context.make
|
95
|
-
context.fail!(
|
96
|
+
context.fail!("a sad end", 10005)
|
96
97
|
|
97
98
|
expect(context).to be_failure
|
99
|
+
expect(context.message).to eq("a sad end")
|
98
100
|
expect(context.error_code).to eq(10005)
|
99
101
|
end
|
100
102
|
|