From d1c098b038b6304945c57a31b1893202d60cba88 Mon Sep 17 00:00:00 2001 From: Bruce MacDonald Date: Mon, 31 Jul 2023 11:49:33 -0400 Subject: [PATCH] tell users to check the server error logs --- cmd/cmd.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/cmd/cmd.go b/cmd/cmd.go index 61658f87..909c0a29 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -278,6 +278,18 @@ func generate(cmd *cobra.Command, model, prompt string) error { } if err := client.Generate(context.Background(), &request, fn); err != nil { + if strings.Contains(err.Error(), "failed to load model") { + // tell the user to check the server log, if it exists locally + home, nestedErr := os.UserHomeDir() + if nestedErr != nil { + // return the original error + return err + } + logPath := filepath.Join(home, ".ollama", "logs", "server.log") + if _, nestedErr := os.Stat(logPath); nestedErr == nil { + err = fmt.Errorf("%w\nFor more details, check the error logs at %s", err, logPath) + } + } return err } @@ -431,7 +443,6 @@ func generateInteractive(cmd *cobra.Command, model string) error { usage() continue } - } else { usage() continue