Skip to content

Commit

Permalink
Trigger host app error correctly (#367)
Browse files Browse the repository at this point in the history
  • Loading branch information
oguzhankoral authored Aug 14, 2024
1 parent 3713abd commit a2ba682
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions speckle_connector_3/src/actions/handle_error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ module Actions
# Action to return error message to UI.
# It is "TopLevelExceptionHandler" equivalent of C#.
class HandleError < Action
# @param error [String] error
# @return [StandardError] error
attr_reader :error

# @param error [StandardError] error
# @param view_name [String] name of the view (binding)
# @param action [Action] action that error happened
# @param parameters [Array<String>] arguments
Expand All @@ -21,19 +24,13 @@ def initialize(error, view_name, action, parameters)
# @return [States::State] the new updated state object
def update_state(state)
# TODO: Log here when it is ready!!!
error_message = "Error: #{@error}\nBinding: #{@view_name}\nAction:#{@action}\nArgs: #{@args}\n"
error = {
error: error_message
}
global_notification = {
type: 2,
title: 'Host App Error',
description: error
host_app_error = {
message: error.message,
error: error,
stackTrace: error.backtrace
}
js_error_script = "#{@view_name}.receiveResponse('#{@args.first}', #{error.to_json})"
new_state = state.with_add_queue_js_command("error_#{@view_name}", js_error_script)
js_global_notification_script = "#{@view_name}.emit('setGlobalNotification', #{global_notification.to_json})"
new_state.with_add_queue_js_command("global_notification_#{@view_name}", js_global_notification_script)
js_error_script = "#{@view_name}.receiveResponse('#{@args.first}', #{host_app_error.to_json})"
state.with_add_queue_js_command("error_#{@view_name}", js_error_script)
end
end
end
Expand Down

0 comments on commit a2ba682

Please sign in to comment.