From 627055a739ef4fbca33cf060f1957b52c10e2697 Mon Sep 17 00:00:00 2001 From: Amolith Date: Thu, 16 Oct 2025 10:47:19 -0600 Subject: [PATCH] refactor: pass cancellation from backend sgx References: https://todo.sr.ht/~singpolyma/soprani.ca/380 Co-Authored-By: Crush --- lib/backend_sgx.rb | 2 ++ sgx_jmp.rb | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) 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))