Skip to content

Commit a23620f

Browse files
authored
fix: Format the error backtrace
1 parent b0a21af commit a23620f

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

lib/functions_framework/server.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,9 @@ def interpret_response response
352352
when ::CloudEvents::CloudEventsError
353353
cloud_events_error_response response
354354
when ::StandardError
355-
error_response "#{response.class}: #{response.message}\n#{response.backtrace}\n"
355+
message = "#{response.class}: #{response.message}"
356+
message = [message, *response.backtrace].join "\n\t"
357+
error_response message
356358
else
357359
error_response "Unexpected response type: #{response.class}"
358360
end

lib/functions_framework/testing.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,8 @@ def interpret_response
335335
json = ::JSON.dump response
336336
string_response json, 200, content_type: "application/json"
337337
when ::StandardError
338-
message = "#{response.class}: #{response.message}\n#{response.backtrace}\n"
338+
message = "#{response.class}: #{response.message}"
339+
message = [message, *response.backtrace].join "\n\t"
339340
string_response message, 500
340341
else
341342
raise "Unexpected response type: #{response.inspect}"

test/test_server.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ def query_server_with_retry server
244244
::Net::HTTP.get_response URI("#{server_url}/")
245245
end
246246
assert_equal "500", response.code
247-
assert_match(/Whoops!/, response.body)
247+
assert_match(/RuntimeError: Whoops!\n\t#{__FILE__}/, response.body)
248248
assert_equal "text/plain; charset=utf-8", response["Content-Type"]
249249
end
250250

0 commit comments

Comments
 (0)