Skip to content

Commit 9d87b8c

Browse files
authored
fix: Stop sending code argument to respond_with_error, it does not accept it (#23)
* fix: Stop sending code argument to respond_with_error, it does not accept it * fix: Corrects the parameter documentation (Thanks Copilot)
1 parent a7653e4 commit 9d87b8c

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
leopard (0.1.5)
4+
leopard (0.1.6)
55
concurrent-ruby (~> 1.1)
66
dry-configurable (~> 1.3)
77
dry-monads (~> 1.9)

examples/echo_endpoint.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ def initialize(a_var = 1)
1212
end
1313

1414
endpoint(:echo) { |msg| Success(msg.data) }
15+
endpoint(:echo_fail) { |msg| Failure({ failure: '*boom*', data: msg.data }.to_json) }
1516
end
1617

1718
if __FILE__ == $PROGRAM_NAME
@@ -22,6 +23,6 @@ def initialize(a_var = 1)
2223
version: '1.0.0',
2324
instance_args: [2],
2425
},
25-
instances: 4,
26+
instances: 1,
2627
)
2728
end

lib/leopard/message_wrapper.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,10 @@ def respond(payload)
3030
end
3131

3232
# @param err [String, Exception] The error message or exception to respond with.
33-
# @param code [Integer] The HTTP status code to use for the error response.
3433
#
3534
# @return [void]
36-
def respond_with_error(err, code: 500)
37-
raw.respond_with_error(err.to_s, code:)
35+
def respond_with_error(err)
36+
raw.respond_with_error(err.to_s)
3837
end
3938

4039
private

test/lib/message_wrapper.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ def respond(payload)
1515
@responded_payload = payload
1616
end
1717

18-
def respond_with_error(err, code:)
19-
@error_args = [err, code]
18+
def respond_with_error(err)
19+
@error_args = [err]
2020
end
2121
end
2222

@@ -57,15 +57,15 @@ def respond_with_error(err, code:)
5757
end
5858

5959
it 'responds with error' do
60-
wrapper.respond_with_error('fail', code: 404)
60+
wrapper.respond_with_error('fail')
6161

62-
assert_equal ['fail', 404], msg.error_args
62+
assert_equal ['fail'], msg.error_args
6363
end
6464

6565
it 'coerces exception objects to strings when responding with error' do
6666
err = StandardError.new('broken')
6767
wrapper.respond_with_error(err)
6868

69-
assert_equal ['broken', 500], msg.error_args
69+
assert_equal ['broken'], msg.error_args
7070
end
7171
end

0 commit comments

Comments
 (0)