From d5af0ca704c07998c0a551b885d8ab0a149c775a Mon Sep 17 00:00:00 2001 From: Alex Potsides Date: Fri, 19 Apr 2024 14:03:56 +0100 Subject: [PATCH] fix: more helpful error messages (#826) Also remove unused types. --- src/factory.ts | 2 +- src/index.ts | 30 ------------------------------ src/kubo/daemon.ts | 14 ++++++++++---- 3 files changed, 11 insertions(+), 35 deletions(-) diff --git a/src/factory.ts b/src/factory.ts index 6b4ea78f..75f5ca0c 100644 --- a/src/factory.ts +++ b/src/factory.ts @@ -68,7 +68,7 @@ class DefaultFactory implements Factory { } if (ctl == null) { - throw new Error('Unsupported type') + throw new Error(`Unsupported type "${type}" - configured types [${[...new Set([this.options.type, ...Object.keys(this.overrides)].filter(Boolean))].join(', ')}]`) } // Save the controller diff --git a/src/index.ts b/src/index.ts index 5cc73b35..a37a8c43 100644 --- a/src/index.ts +++ b/src/index.ts @@ -158,36 +158,6 @@ export interface Node } -export interface InitOptions { - pass?: string - bits?: number - algorithm?: string - emptyRepo?: boolean - profiles?: string[] - allowNew?: boolean - privateKey?: string -} - -export interface PreloadOptions { - enabled?: boolean - addresses?: string[] -} - -export interface ExperimentalOptions { - sharding?: boolean - ipnsPubsub?: boolean -} - -export interface CircuitRelayHopOptions { - enabled: boolean - active: boolean -} - -export interface CircuitRelayOptions { - enabled: boolean - hop: CircuitRelayHopOptions -} - export interface NodeOptions { /** * The type of controller diff --git a/src/kubo/daemon.ts b/src/kubo/daemon.ts index 79458f3e..cf3aad69 100644 --- a/src/kubo/daemon.ts +++ b/src/kubo/daemon.ts @@ -95,10 +95,16 @@ export default class KuboDaemon implements KuboNode { * this will be called automatically when the process is exited. */ async cleanup (): Promise { - await fs.rm(this.repo, { - recursive: true, - force: true - }) + try { + await fs.rm(this.repo, { + recursive: true, + force: true + }) + } catch (err: any) { + if (err.code !== 'EPERM') { + throw err + } + } } async init (args?: KuboInitOptions): Promise {