mirror of
https://github.com/enso-org/enso.git
synced 2024-12-24 16:21:37 +03:00
Truncate long error messages (#7180)
close #6958 # Important Notes On the screenshot, the `max_length` is set to 10 to illustrate the new behavior. ![2023-06-30-205255_758x483_scrot](https://github.com/enso-org/enso/assets/357683/0b593b12-4469-49fd-a2e5-216ce54eb264)
This commit is contained in:
parent
c866aa7fb5
commit
bb862141e5
@ -284,3 +284,9 @@ Row.to_default_visualization_data self =
|
||||
Table.to_lazy_visualization_data : Vector Integer -> Vector Integer -> Vector Integer -> Integer -> Text
|
||||
Table.to_lazy_visualization_data self table_cell_position text_window_position text_window_size chunk_size =
|
||||
Table_Visualization.get_lazy_visualization_data self table_cell_position text_window_position text_window_size chunk_size
|
||||
|
||||
## PRIVATE
|
||||
Truncate message to the provided max length.
|
||||
truncate : Text -> Integer -> Text -> Text
|
||||
truncate message max_length=256 suffix='...' =
|
||||
if message.length > max_length then message.take max_length-suffix.length + suffix else message
|
||||
|
@ -6,7 +6,7 @@ import project.Helpers
|
||||
default_preprocessor x =
|
||||
result = x.to_default_visualization_data
|
||||
case result.is_error of
|
||||
True -> x.to_display_text . to_json
|
||||
True -> Helpers.truncate x.to_display_text . to_json
|
||||
False -> result
|
||||
|
||||
|
||||
@ -23,7 +23,8 @@ error_preprocessor x =
|
||||
result = x.map_error err->
|
||||
message = err.to_display_text
|
||||
stack_trace = x.get_stack_trace_text.if_nothing "" . split '\n'
|
||||
full_message = message + if stack_trace.length > 1 then " (" + stack_trace.at 1 . trim +")" else ""
|
||||
truncated_message = Helpers.truncate message
|
||||
full_message = truncated_message + if stack_trace.length > 1 then " (" + stack_trace.at 1 . trim +")" else ""
|
||||
JS_Object.from_pairs [['kind', 'Dataflow'], ['message', full_message]] . to_json
|
||||
|
||||
if result.is_error then result.catch else ok
|
||||
|
Loading…
Reference in New Issue
Block a user