Propagate DB errors and clipboard failures

The common tracker pattern show command swallowed every error from
loading the linked common third party, hiding real database failures
behind silent partial output. Only tolerate ErrResourceNotFound now and
wrap any other error so the command fails loudly.

In the console, the copy-to-clipboard button reported success
unconditionally. Await the clipboard write and surface an error toast
when it rejects, guarding against a missing common tracker id.

Signed-off-by: Émile Ré <emile@probo.com>
This commit is contained in:
Émile Ré
2026-06-08 18:42:47 +02:00
parent 8349ca3be3
commit 83d36d345f
2 changed files with 17 additions and 3 deletions

View File

@@ -118,8 +118,18 @@ export function TrackerPatternPropertiesSection({
type="button"
className="p-1 rounded hover:bg-bg-hover transition-colors cursor-pointer"
onClick={() => {
void navigator.clipboard.writeText(pattern.commonTrackerPatternId);
toast({ title: __("Copied"), description: __("Common Tracker ID copied to clipboard"), variant: "success" });
const commonTrackerPatternId = pattern.commonTrackerPatternId;
if (!commonTrackerPatternId) {
return;
}
void (async () => {
try {
await navigator.clipboard.writeText(commonTrackerPatternId);
toast({ title: __("Copied"), description: __("Common Tracker ID copied to clipboard"), variant: "success" });
} catch {
toast({ title: __("Error"), description: __("Failed to copy Common Tracker ID"), variant: "error" });
}
})();
}}
>
<IconSquareBehindSquare2 size={16} />

View File

@@ -70,7 +70,11 @@ func newCmdShow(f *cmdutil.Factory) *cobra.Command {
if pattern.CommonThirdPartyID != nil {
var party coredata.CommonThirdParty
if err := party.LoadByID(ctx, conn, *pattern.CommonThirdPartyID); err == nil {
if err := party.LoadByID(ctx, conn, *pattern.CommonThirdPartyID); err != nil {
if !errors.Is(err, coredata.ErrResourceNotFound) {
return fmt.Errorf("cannot load common third party: %w", err)
}
} else {
thirdPartyName = party.Name
}
}