diff --git a/plugin/src/software/aws/toolkits/eclipse/amazonq/exception/LspError.java b/plugin/src/software/aws/toolkits/eclipse/amazonq/exception/LspError.java index 7e18fad6..7ac039fe 100644 --- a/plugin/src/software/aws/toolkits/eclipse/amazonq/exception/LspError.java +++ b/plugin/src/software/aws/toolkits/eclipse/amazonq/exception/LspError.java @@ -13,12 +13,16 @@ public enum LspError { INVALID_REMOTE_SERVER("Invalid Remote Server"), INVALID_CACHE_SERVER("Invalid Cache Server"), MANIFEST_FETCH_ERROR("Error fetching manifest"), + MANIFEST_REMOTE_FETCH_ERROR("Error fetching manifest from remote location"), SERVER_FETCH_ERROR("Error fetching server"), UNEXPECTED_CACHE_ERROR("Error while caching file"), + UNEXPECTED_MANIFEST_CACHE_ERROR("Error while caching Manifest file"), NO_COMPATIBLE_LSP("No LSP version found matching requirements"), + NO_VALID_SERVER_FALLBACK("No valid server version to fallback to."), + ARTIFACT_VALIDATION_ERROR("Error validating artifact"), INVALID_LAUNCH_PROPERTIES("Invalid launch properties"), INVALID_WORKING_DIRECTORY("Invalid working directory"), - EXTRACTION_ERROR("Error or invalid zip files"), + SERVER_ZIP_EXTRACTION_ERROR("Error extracting server zip files"), UNKNOWN("Unknown"); private final String value; diff --git a/plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/manager/fetcher/RemoteLspFetcher.java b/plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/manager/fetcher/RemoteLspFetcher.java index b297ee12..37382e96 100644 --- a/plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/manager/fetcher/RemoteLspFetcher.java +++ b/plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/manager/fetcher/RemoteLspFetcher.java @@ -141,7 +141,7 @@ public LspFetchResult fetch(final PluginPlatform platform, final PluginArchitect } String failureReason = "Unable to find a compatible version of Amazon Q Language Server."; - setErrorReason(LspError.NO_COMPATIBLE_LSP.toString()); + setErrorReason(LspError.NO_VALID_SERVER_FALLBACK.toString()); emitGetServer(Result.FAILED, null, LanguageServerLocation.UNKNOWN, start); throw new AmazonQPluginException(failureReason); } @@ -260,12 +260,14 @@ private boolean downloadContentFromRemote(final Content content, final Path down return true; } else { ArtifactUtils.deleteDirectory(tempFolder); + setErrorReason(LspError.ARTIFACT_VALIDATION_ERROR.toString()); } } else { setErrorReason(LspError.SERVER_FETCH_ERROR + "-" + response.statusCode()); throw new AmazonQPluginException("Failed to download remote LSP artifact. Response code: " + response.statusCode()); } } catch (Exception ex) { + //TODO: account for these failures in telemtry emissions Activator.getLogger().error("Error downloading from remote", ex); } return false; @@ -283,7 +285,7 @@ private boolean extractZipFilesFromRemote(final Path downloadDirectory) { } catch (Exception e) { String errorMessage = String.format("Failed to extract zip files in %s", downloadDirectory); Activator.getLogger().error(errorMessage, e); - setErrorReason(LspError.EXTRACTION_ERROR.toString()); + setErrorReason(LspError.SERVER_ZIP_EXTRACTION_ERROR.toString()); return false; } } @@ -298,7 +300,7 @@ private boolean extractZip(final Path zipFile, final Path downloadDirectory) { ArtifactUtils.extractFile(zipFile, unzipFolder); } catch (IOException e) { Activator.getLogger().error(String.format("Failed to extract zip contents for: %s, some features may not work", zipFile.toString()), e); - setErrorReason(ExceptionMetadata.scrubException(LspError.EXTRACTION_ERROR.toString(), e)); + setErrorReason(ExceptionMetadata.scrubException(LspError.SERVER_ZIP_EXTRACTION_ERROR.toString(), e)); return false; } return true; diff --git a/plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/manager/fetcher/VersionManifestFetcher.java b/plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/manager/fetcher/VersionManifestFetcher.java index 2a8cdf3b..b586323c 100644 --- a/plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/manager/fetcher/VersionManifestFetcher.java +++ b/plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/manager/fetcher/VersionManifestFetcher.java @@ -117,7 +117,7 @@ private Optional getResourceFromCache() { } } catch (Exception e) { Activator.getLogger().error("Error fetching resource from cache", e); - emitGetManifest(null, ManifestLocation.CACHE, ExceptionMetadata.scrubException(LspError.MANIFEST_FETCH_ERROR.toString(), e)); + emitGetManifest(null, ManifestLocation.CACHE, ExceptionMetadata.scrubException(LspError.UNEXPECTED_MANIFEST_CACHE_ERROR.toString(), e)); } return Optional.empty(); } @@ -176,7 +176,7 @@ private Optional validateAndCacheLatest(final HttpResponse res return manifest; } catch (Exception e) { Activator.getLogger().error("Failed to cache manifest file", e); - emitGetManifest(null, ManifestLocation.REMOTE, ExceptionMetadata.scrubException(LspError.UNEXPECTED_CACHE_ERROR.toString(), e)); + emitGetManifest(null, ManifestLocation.REMOTE, ExceptionMetadata.scrubException(LspError.MANIFEST_REMOTE_FETCH_ERROR.toString(), e)); } return Optional.empty(); }