@sparkdotfi/abi-cli 0.2.0-20250904.f84da601-canary → 0.2.0-20250908.2e329053
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/cli.js +24 -2
- package/package.json +1 -1
package/dist/src/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NodeContext, NodeRuntime } from '@effect/platform-node';
|
|
2
|
-
import { Effect, Layer, Logger } from 'effect';
|
|
2
|
+
import { Effect, Layer, Logger, Option } from 'effect';
|
|
3
3
|
import { configLayer } from './config/Config.js';
|
|
4
4
|
import { abiFetcherLayer } from './fetch/AbiFetcher.js';
|
|
5
5
|
import { blockchainClientRepositoryLayer } from './fetch/BlockchainClientRepository.js';
|
|
@@ -10,4 +10,26 @@ const blockchainClientRepository = Layer.provide(blockchainClientRepositoryLayer
|
|
|
10
10
|
const abiFetcher = Layer.provide(abiFetcherLayer, [blockchainClientRepository, configLayer]);
|
|
11
11
|
const logger = Logger.replace(Logger.defaultLogger, AbiCliLogger);
|
|
12
12
|
const mainDeps = Layer.mergeAll(configLayer, blockchainClientRepository, abiFetcher, NodeContext.layer, progressBarLayer);
|
|
13
|
-
main.pipe(Effect.provide(mainDeps), Effect.provide(logger), Effect.withSpan('cli'), NodeRuntime.runMain({ disablePrettyLogger: true }));
|
|
13
|
+
main.pipe(Effect.provide(mainDeps), Effect.provide(logger), Effect.withSpan('cli'), prettyPrintErrors(), NodeRuntime.runMain({ disablePrettyLogger: true }));
|
|
14
|
+
function prettyPrintErrors() {
|
|
15
|
+
return Effect.catchSome((failure) => {
|
|
16
|
+
// print full stack traces if debug is on
|
|
17
|
+
if (process.env.DEBUG) {
|
|
18
|
+
return Option.none();
|
|
19
|
+
}
|
|
20
|
+
const anyFailure = failure;
|
|
21
|
+
if (anyFailure.cause) {
|
|
22
|
+
console.error(`${anyFailure.message}: ${anyFailure.cause.message}`);
|
|
23
|
+
return Option.some(Effect.fail('Error occurred'));
|
|
24
|
+
}
|
|
25
|
+
if (anyFailure._tag) {
|
|
26
|
+
console.error(`Error occurred: ${prettyPrintFailure(anyFailure)}`);
|
|
27
|
+
return Option.some(Effect.fail('Error occurred'));
|
|
28
|
+
}
|
|
29
|
+
return Option.none();
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function prettyPrintFailure(error) {
|
|
33
|
+
const props = Object.getOwnPropertyNames(error).filter((p) => p !== 'stack' && p !== '_tag');
|
|
34
|
+
return `${error._tag}(${props.map((p) => `${p}=${error[p]}`).join(', ')})`;
|
|
35
|
+
}
|