From f7afbf8c6d494180a246efb198f0996ef5f14e44 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 23764d9967cff4351bf9e9143ccc9fc720e90036..a06786afe4882b00373621440ead3e6d6061a129 100644 --- a/lib/backend_sgx.rb +++ b/lib/backend_sgx.rb @@ -11,6 +11,8 @@ require_relative "form_to_h" class BackendSgx COMMANDS_DISCO_NODE = "http://jabber.org/protocol/commands" + 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))