File tree Expand file tree Collapse file tree 1 file changed +11
-9
lines changed Expand file tree Collapse file tree 1 file changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ def retry
3434
3535 private
3636 JSON_OVERHEAD = 256
37- DEFAULT_BACKTRACE_LINES_LIMIT = 400
37+ DEFAULT_ERROR_SIZE_LIMIT = 64 . kilobytes
3838
3939 def expand_error_details_from_exception
4040 if exception
@@ -51,19 +51,21 @@ def exception_message
5151 end
5252
5353 def exception_backtrace
54- if column = self . class . connection . schema_cache . columns_hash ( self . class . table_name ) [ "error" ]
55- limit = column . limit - exception_class_name . bytesize - exception_message . bytesize - JSON_OVERHEAD
54+ limit = determine_backtrace_size_limit
5655
57- if exception . backtrace . to_json . bytesize <= limit
58- exception . backtrace
59- else
60- truncate_backtrace ( exception . backtrace , limit )
61- end
56+ if exception . backtrace . to_json . bytesize <= limit
57+ exception . backtrace
6258 else
63- exception . backtrace . take ( DEFAULT_BACKTRACE_LINES_LIMIT )
59+ truncate_backtrace ( exception . backtrace , limit )
6460 end
6561 end
6662
63+ def determine_backtrace_size_limit
64+ column = self . class . connection . schema_cache . columns_hash ( self . class . table_name ) [ "error" ]
65+
66+ ( column &.limit || DEFAULT_ERROR_SIZE_LIMIT ) - exception_class_name . bytesize - exception_message . bytesize - JSON_OVERHEAD
67+ end
68+
6769 def truncate_backtrace ( lines , limit )
6870 [ ] . tap do |truncated_backtrace |
6971 lines . each do |line |
You can’t perform that action at this time.
0 commit comments