]> git.codecow.com Git - libnemo.git/commitdiff
Provide more info when wallet destruction fails.
authorChris Duncan <chris@zoso.dev>
Wed, 23 Jul 2025 15:21:02 +0000 (08:21 -0700)
committerChris Duncan <chris@zoso.dev>
Wed, 23 Jul 2025 15:21:02 +0000 (08:21 -0700)
src/lib/wallets/wallet.ts

index 673435b0928b23a3d162f88ceb9c6def04c850a9..97898e4a7814712d732796176005d53de9a7b83d 100644 (file)
@@ -136,20 +136,23 @@ export abstract class Wallet {
        * allow garbage collection.\r
        */\r
        async destroy (): Promise<void> {\r
-               let i = 0\r
-               for (const a in this.#accounts) {\r
-                       await this.#accounts[a].destroy()\r
-                       delete this.#accounts[a]\r
-                       i++\r
+               try {\r
+                       for (const a in this.#accounts) {\r
+                               await this.#accounts[a].destroy()\r
+                               delete this.#accounts[a]\r
+                       }\r
+                       bytes.erase(this.#s)\r
+                       this.#s = null\r
+                       this.#m = null\r
+                       await SafeWorker.assign<boolean>({\r
+                               store: 'Wallet',\r
+                               method: 'destroy',\r
+                               [this.id]: this.id\r
+                       })\r
+               } catch (err) {\r
+                       console.error(err)\r
+                       throw new Error('failed to destroy wallet', { cause: err })\r
                }\r
-               this.#m = null\r
-               bytes.erase(this.#s)\r
-               this.#s = null\r
-               await SafeWorker.assign({\r
-                       store: 'Wallet',\r
-                       method: 'destroy',\r
-                       [this.id]: this.id\r
-               })\r
        }\r
 \r
        /**\r