Skip to content

Commit cc56829

Browse files
committed
Change error response content type to text/plain for string errors
1 parent 39d5717 commit cc56829

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/hooks/app/api.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,9 @@ def self.create(config:, endpoints:, log:)
126126
status e.status
127127
case e.body
128128
when String
129-
# Even string errors are now JSON-encoded with the default JSON format
130-
content_type "application/json"
129+
# if error! was called with a string, we assume it's a simple text error
130+
# example: error!("simple text error", 400) -> should return a plain text response
131+
content_type "text/plain"
131132
error_response = e.body
132133
else
133134
# Let Grape handle JSON conversion with the default format

0 commit comments

Comments
 (0)