From 99d49c9a0be5edadfc108de3cd95163d41f3e4ef Mon Sep 17 00:00:00 2001 From: Clemens Lang Date: Wed, 24 Jul 2024 17:21:41 +0200 Subject: [PATCH] snapshot: Handle errors with unknown snapshot IDs (cherry picked from commit 6b8b5ca3b756f0a6bae8d62ef5f12623238b5f17) --- src/macports1.0/snapshot.tcl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/macports1.0/snapshot.tcl b/src/macports1.0/snapshot.tcl index 50f943522f..f9a1a06fea 100644 --- a/src/macports1.0/snapshot.tcl +++ b/src/macports1.0/snapshot.tcl @@ -42,8 +42,8 @@ namespace eval snapshot { ui_msg " port snapshot --delete " } - proc main {opts} { - # Function to create a snapshot of the current state of ports. + proc main {opts} { + # Function to create a snapshot of the current state of ports. # # Args: # opts - The options passed in. @@ -110,7 +110,10 @@ namespace eval snapshot { return 0 } "diff" { - set snapshot [registry::snapshot get_by_id [dict get $opts ports_snapshot_diff]] + if {[catch {set snapshot [registry::snapshot get_by_id [dict get $opts ports_snapshot_diff]]} result]} { + ui_error "Failed to obtain snapshot with ID [dict get $opts ports_snapshot_diff]: $result" + return 1 + } array set diff [diff $snapshot] set show_all [dict exists $opts ports_snapshot_all] set note ""