From 4987a457591fc7ce198644d69691a0e70b27428c Mon Sep 17 00:00:00 2001 From: "Aleksei.Tirman" Date: Mon, 18 Nov 2024 12:07:03 +0200 Subject: [PATCH] KTOR-7748 Fix after rebase --- internal/app/cli/command/generate.go | 6 +++--- internal/app/cli/output.go | 12 +++++------- internal/app/i18n/bundle.en.go | 7 +++++-- internal/app/i18n/messages.go | 5 ++++- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/internal/app/cli/command/generate.go b/internal/app/cli/command/generate.go index 2065d55..4db06a9 100644 --- a/internal/app/cli/command/generate.go +++ b/internal/app/cli/command/generate.go @@ -43,7 +43,7 @@ func Generate(client *http.Client, projectDir, projectName string, plugins []str if err != nil { cli.ExitWithError(err, projectDir, hasGlobalLog, homeDir) } - - fmt.Printf(i18n.Get(i18n.JdkDownloaded, jdkPath)) - cli.PrintCommands(projectDir, false, jdkPath) + fmt.Printf(i18n.Get(i18n.JdkDownloaded, jdkPath)) + cli.PrintCommands(projectDir, false, jdkPath) + } } diff --git a/internal/app/cli/output.go b/internal/app/cli/output.go index 5737cf5..8a969a7 100644 --- a/internal/app/cli/output.go +++ b/internal/app/cli/output.go @@ -12,7 +12,6 @@ import ( "os" "runtime" "strings" - "syscall" ) func ExitWithError(err error, projectDir string, hasGlobalLog bool, homeDir string) { @@ -48,13 +47,12 @@ func HandleAppError(projectDir string, err error) (reportLog bool) { fmt.Fprintf(os.Stderr, i18n.Get(i18n.GenServerTimeoutError)) case app.NetworkError: fmt.Fprintf(os.Stderr, i18n.Get(i18n.NetworkError)) - fmt.Fprintf(os.Stderr, "Unexpected network error occurred. Please check your Internet connection.\n") case app.OpenApiDownloadJarError: - fmt.Fprintf(os.Stderr, "Unexpected error occurred while downloading OpenAPI utility. Please try again later.\n") + fmt.Fprintf(os.Stderr, i18n.Get(i18n.DownloadOpenAPIJarError)) case app.OpenApiExecuteJarError: - fmt.Fprintf(os.Stderr, "Unable to execute OpenAPI utility.\n") + fmt.Fprintf(os.Stderr, i18n.Get(i18n.OpenApiExecuteJarError)) case app.ExternalCommandError: - fmt.Fprintf(os.Stderr, "Unexpected error occcured while executing an external command.\n") + fmt.Fprintf(os.Stderr, i18n.Get(i18n.ExternalCommandError)) case app.InternalError: fmt.Fprintf(os.Stderr, i18n.Get(i18n.InternalError)) case app.ProjectDirError: @@ -64,9 +62,9 @@ func HandleAppError(projectDir string, err error) (reportLog bool) { switch { case errors.Is(pe.Err, os.ErrExist): - fmt.Fprintf(os.Stderr, i18n.Get(i18n.ProjectDirExist, pe.Path)) // "The project directory %s already exists and not empty.\n" + fmt.Fprintf(os.Stderr, i18n.Get(i18n.ProjectDirExistAndNotEmpty, pe.Path)) case errors.Is(pe.Err, os.ErrPermission): - fmt.Fprintf(os.Stderr, i18n.Get(i18n.NoPermsCreateProjectDir, pe.Path)) // "Not enough permissions to create project directory %s.\n", pe.Path) + fmt.Fprintf(os.Stderr, i18n.Get(i18n.NoPermsCreateProjectDir, pe.Path)) } case app.ProjectExtractError: fmt.Fprintf(os.Stderr, i18n.Get(i18n.ProjectExtractError, projectDir)) diff --git a/internal/app/i18n/bundle.en.go b/internal/app/i18n/bundle.en.go index 8b0a377..66fd7dc 100644 --- a/internal/app/i18n/bundle.en.go +++ b/internal/app/i18n/bundle.en.go @@ -14,9 +14,9 @@ var en = map[Message]string{ JdkVerificationFailed: "JDK verification failed. Retrying...", GenServerError: "Error connecting to the generation server. Please try again later.\n", GenServerTimeoutError: "Connection to the generation server timed out. Please try again later.\n", - NetworkError: "Network error while connecting to the generation server. Check your Internet connection and try again.\n", + NetworkError: "Network error. Check your Internet connection and try again.\n", InternalError: "Internal error. To get help, report the issue on YouTrack: https://youtrack.jetbrains.com/newIssue?project=ktor.\n", - ProjectDirExist: "The project directory %s already exists.\n", + ProjectDirExistAndNotEmpty: "The project directory %s already exists and is not empty.\n", NoPermsCreateProjectDir: "Insufficient permissions to create project directory %s.\n", ProjectExtractError: "Failed to extract downloaded archive to the directory %s.\n", JdkExtractError: "Failed to extract downloaded JDK to the directory %s.\n", @@ -67,4 +67,7 @@ var en = map[Message]string{ DownloadingProjectArchiveProgress: "Downloading project archive... ", ProjectNameRequired: "Project name is empty", ProjectNameAllowedChars: "Only Latin characters, digits, '_', '-' and '.' are allowed for the project name", + DownloadOpenAPIJarError: "Error downloading OpenAPI utility. Please try again later.\n", + OpenApiExecuteJarError: "Failed to execute OpenAPI utility.\n", + ExternalCommandError: "Error executing an external command.\n", } diff --git a/internal/app/i18n/messages.go b/internal/app/i18n/messages.go index 5ca70e5..cbcb678 100644 --- a/internal/app/i18n/messages.go +++ b/internal/app/i18n/messages.go @@ -18,7 +18,7 @@ const ( GenServerTimeoutError NetworkError InternalError - ProjectDirExist + ProjectDirExistAndNotEmpty NoPermsCreateProjectDir ProjectExtractError JdkExtractError @@ -69,4 +69,7 @@ const ( DownloadingProjectArchiveProgress ProjectNameRequired ProjectNameAllowedChars + DownloadOpenAPIJarError + OpenApiExecuteJarError + ExternalCommandError )