From 0e090769b836a441f762138375ef2db941b1e4fb Mon Sep 17 00:00:00 2001 From: Armando Andini Date: Wed, 3 May 2023 05:34:33 -0300 Subject: [PATCH] chore: stop capturing initialize errors (#474) Instead of passing Ape/Truffle/Foundry initialization errors to sentry, we log for the user only. We don't rethrow truffle project errors, matching the pattern used in other adapters. Resolves #473. --- server/src/frameworks/Ape/ApeProject.ts | 2 +- server/src/frameworks/Foundry/FoundryProject.ts | 3 +-- server/src/frameworks/Truffle/TruffleProject.ts | 6 ++++-- server/src/services/initialization/indexWorkspaceFolders.ts | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/server/src/frameworks/Ape/ApeProject.ts b/server/src/frameworks/Ape/ApeProject.ts index 6b6ce2a2..e2ff7b69 100644 --- a/server/src/frameworks/Ape/ApeProject.ts +++ b/server/src/frameworks/Ape/ApeProject.ts @@ -82,7 +82,7 @@ export class ApeProject extends Project { } } catch (error) { this.initializeError = `${error}`; - this.serverState.logger.error(this.initializeError); + this.serverState.logger.info(this.initializeError); } return; diff --git a/server/src/frameworks/Foundry/FoundryProject.ts b/server/src/frameworks/Foundry/FoundryProject.ts index 8818bd98..db7520dc 100644 --- a/server/src/frameworks/Foundry/FoundryProject.ts +++ b/server/src/frameworks/Foundry/FoundryProject.ts @@ -66,8 +66,6 @@ export class FoundryProject extends Project { ); this.remappings = parseRemappings(rawRemappings); } catch (error: any) { - this.serverState.logger.error(error.toString()); - switch (error.code) { case 134: this.initializeError = @@ -79,6 +77,7 @@ export class FoundryProject extends Project { default: this.initializeError = `Unexpected error while running \`forge\`: ${error}`; } + this.serverState.logger.info(this.initializeError); } return; diff --git a/server/src/frameworks/Truffle/TruffleProject.ts b/server/src/frameworks/Truffle/TruffleProject.ts index 02ad1871..874603c7 100644 --- a/server/src/frameworks/Truffle/TruffleProject.ts +++ b/server/src/frameworks/Truffle/TruffleProject.ts @@ -69,7 +69,7 @@ export class TruffleProject extends Project { const errorMessage = `Truffle module not found. Ensure it's installed globally or locally.`; this.status = Status.INITIALIZED_FAILURE; this.initializeError = errorMessage; - throw new Error(errorMessage); + this.serverState.logger.info(this.initializeError); } try { @@ -90,11 +90,13 @@ export class TruffleProject extends Project { this.serverState.solcVersions, configSolcVersion ); + if (resolvedSolcVersion === null) { throw new Error( `No version satisfies ${configSolcVersion}. Available versions are: ${this.serverState.solcVersions}` ); } + this.resolvedSolcVersion = resolvedSolcVersion; // Load contracts directory @@ -113,7 +115,7 @@ export class TruffleProject extends Project { const errorMessage = `Error loading config file ${this.configPath}: ${error}`; this.status = Status.INITIALIZED_FAILURE; this.initializeError = errorMessage; - throw new Error(errorMessage); + this.serverState.logger.info(this.initializeError); } } diff --git a/server/src/services/initialization/indexWorkspaceFolders.ts b/server/src/services/initialization/indexWorkspaceFolders.ts index 945d2191..8e0ace52 100644 --- a/server/src/services/initialization/indexWorkspaceFolders.ts +++ b/server/src/services/initialization/indexWorkspaceFolders.ts @@ -83,7 +83,7 @@ export async function indexWorkspaceFolders( try { await foundProject.initialize(); } catch (error) { - logger.error(`Error initializing ${foundProject.basePath}: ${error}`); + logger.error(error); } span?.finish();