diff --git a/lib/backend_sgx.rb b/lib/backend_sgx.rb index 743105bb0080a416082d27c2f3f94f5626a20fcd..c0ef5557d4b359a986fafb3f4efd8424cafdeeb9 100644 --- a/lib/backend_sgx.rb +++ b/lib/backend_sgx.rb @@ -9,6 +9,8 @@ require_relative "not_loaded" require_relative "form_to_h" class BackendSgx + class CanceledError < StandardError; end + using FormToH value_semantics do diff --git a/sgx_jmp.rb b/sgx_jmp.rb index ca024c70c1e1acd59cac4f1711303d3bf8c0ef1d..45e0136ad92c5dafbe3528da0a3a1e56733ba01c 100644 --- a/sgx_jmp.rb +++ b/sgx_jmp.rb @@ -898,8 +898,10 @@ Command.new( raise "PIN and confirm PIN must match." unless pin == confirm_pin customer.set_port_out_pin(pin) - }.then do + }.then { Command.finish("Your port-out PIN has been set.") + }.catch_only(BackendSgx::CanceledError) do |e| + Command.finish(e.message, status: :canceled) end end }.register(self).then(&CommandList.method(:register))