Skip to content

Commit

Permalink
KTOR-7748 Fix after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
Stexxe committed Nov 18, 2024
1 parent 80a1f90 commit 4987a45
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
6 changes: 3 additions & 3 deletions internal/app/cli/command/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
12 changes: 5 additions & 7 deletions internal/app/cli/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"os"
"runtime"
"strings"
"syscall"
)

func ExitWithError(err error, projectDir string, hasGlobalLog bool, homeDir string) {
Expand Down Expand Up @@ -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:
Expand All @@ -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))
Expand Down
7 changes: 5 additions & 2 deletions internal/app/i18n/bundle.en.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
}
5 changes: 4 additions & 1 deletion internal/app/i18n/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const (
GenServerTimeoutError
NetworkError
InternalError
ProjectDirExist
ProjectDirExistAndNotEmpty
NoPermsCreateProjectDir
ProjectExtractError
JdkExtractError
Expand Down Expand Up @@ -69,4 +69,7 @@ const (
DownloadingProjectArchiveProgress
ProjectNameRequired
ProjectNameAllowedChars
DownloadOpenAPIJarError
OpenApiExecuteJarError
ExternalCommandError
)

0 comments on commit 4987a45

Please sign in to comment.