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
34
34
35
35
private
36
36
JSON_OVERHEAD = 256
37
- DEFAULT_BACKTRACE_LINES_LIMIT = 400
37
+ DEFAULT_ERROR_SIZE_LIMIT = 64 . kilobytes
38
38
39
39
def expand_error_details_from_exception
40
40
if exception
@@ -51,19 +51,21 @@ def exception_message
51
51
end
52
52
53
53
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
56
55
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
62
58
else
63
- exception . backtrace . take ( DEFAULT_BACKTRACE_LINES_LIMIT )
59
+ truncate_backtrace ( exception . backtrace , limit )
64
60
end
65
61
end
66
62
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
+
67
69
def truncate_backtrace ( lines , limit )
68
70
[ ] . tap do |truncated_backtrace |
69
71
lines . each do |line |
You can’t perform that action at this time.
0 commit comments