Skip to content

Commit

Permalink
chore: stop capturing initialize errors (#474)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
antico5 authored and kanej committed May 3, 2023
1 parent a64b470 commit 0e09076
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion server/src/frameworks/Ape/ApeProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions server/src/frameworks/Foundry/FoundryProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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;
Expand Down
6 changes: 4 additions & 2 deletions server/src/frameworks/Truffle/TruffleProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand All @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 0e09076

Please sign in to comment.