Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

chore: tweak error message

Stevenff81ea602d6b
diff --git a/bin/memos/main.go b/bin/memos/main.go
index e8181bced..c28d1aeed 100644
--- a/bin/memos/main.go
+++ b/bin/memos/main.go
@@ -14,7 +14,7 @@ import (
"github.com/usememos/memos/internal/jobs"
"github.com/usememos/memos/server"
- _profile "github.com/usememos/memos/server/profile"
+ "github.com/usememos/memos/server/profile"
"github.com/usememos/memos/store"
"github.com/usememos/memos/store/db"
)
@@ -31,22 +31,22 @@ const (
)
var (
- profile *_profile.Profile
- mode string
- addr string
- port int
- data string
- driver string
- dsn string
- serveFrontend bool
- allowedOrigins []string
+ mode string
+ addr string
+ port int
+ data string
+ driver string
+ dsn string
+ serveFrontend bool
+ allowedOrigins []string
+ instanceProfile *profile.Profile
rootCmd = &cobra.Command{
Use: "memos",
Short: `An open source, lightweight note-taking service. Easily capture and share your great thoughts.`,
Run: func(_cmd *cobra.Command, _args []string) {
ctx, cancel := context.WithCancel(context.Background())
- dbDriver, err := db.NewDBDriver(profile)
+ dbDriver, err := db.NewDBDriver(instanceProfile)
if err != nil {
cancel()
slog.Error("failed to create db driver", err)
@@ -58,14 +58,14 @@ var (
return
}
- storeInstance := store.New(dbDriver, profile)
+ storeInstance := store.New(dbDriver, instanceProfile)
if err := storeInstance.MigrateManually(ctx); err != nil {
cancel()
slog.Error("failed to migrate manually", err)
return
}
- s, err := server.NewServer(ctx, profile, storeInstance)
+ s, err := server.NewServer(ctx, instanceProfile, storeInstance)
if err != nil {
cancel()
slog.Error("failed to create server", err)
@@ -162,7 +162,7 @@ func init() {
func initConfig() {
viper.AutomaticEnv()
var err error
- profile, err = _profile.GetProfile()
+ instanceProfile, err = profile.GetProfile()
if err != nil {
fmt.Printf("failed to get profile, error: %+v\n", err)
return
@@ -179,15 +179,15 @@ mode: %s
driver: %s
frontend: %t
---
-`, profile.Version, profile.Data, profile.DSN, profile.Addr, profile.Port, profile.Mode, profile.Driver, profile.Frontend)
+`, instanceProfile.Version, instanceProfile.Data, instanceProfile.DSN, instanceProfile.Addr, instanceProfile.Port, instanceProfile.Mode, instanceProfile.Driver, instanceProfile.Frontend)
}
func printGreetings() {
print(greetingBanner)
- if len(profile.Addr) == 0 {
- fmt.Printf("Version %s has been started on port %d\n", profile.Version, profile.Port)
+ if len(instanceProfile.Addr) == 0 {
+ fmt.Printf("Version %s has been started on port %d\n", instanceProfile.Version, instanceProfile.Port)
} else {
- fmt.Printf("Version %s has been started on address '%s' and port %d\n", profile.Version, profile.Addr, profile.Port)
+ fmt.Printf("Version %s has been started on address '%s' and port %d\n", instanceProfile.Version, instanceProfile.Addr, instanceProfile.Port)
}
fmt.Printf(`---
See more in:
diff --git a/server/route/api/v2/auth_service.go b/server/route/api/v2/auth_service.go
index c97cc626c..1cf681a9d 100644
--- a/server/route/api/v2/auth_service.go
+++ b/server/route/api/v2/auth_service.go
@@ -30,7 +30,7 @@ func (s *APIV2Service) GetAuthStatus(ctx context.Context, _ *apiv2pb.GetAuthStat
if user == nil {
// Set the cookie header to expire access token.
if err := s.clearAccessTokenCookie(ctx); err != nil {
- return nil, status.Errorf(codes.Internal, "failed to set grpc header")
+ return nil, status.Errorf(codes.Internal, "failed to set grpc header: %v", err)
}
return nil, status.Errorf(codes.Unauthenticated, "user not found")
}
diff --git a/server/route/api/v2/memo_service.go b/server/route/api/v2/memo_service.go
index bba8a887c..339020f88 100644
--- a/server/route/api/v2/memo_service.go
+++ b/server/route/api/v2/memo_service.go
@@ -106,7 +106,7 @@ func (s *APIV2Service) ListMemos(ctx context.Context, request *apiv2pb.ListMemos
memoFind.Offset = &offset
memos, err := s.Store.ListMemos(ctx, memoFind)
if err != nil {
- return nil, status.Errorf(codes.Internal, "failed to list memos")
+ return nil, status.Errorf(codes.Internal, "failed to list memos: %v", err)
}
memoMessages := []*apiv2pb.Memo{}
@@ -459,7 +459,7 @@ func (s *APIV2Service) GetUserMemosStats(ctx context.Context, request *apiv2pb.G
memos, err := s.Store.ListMemos(ctx, memoFind)
if err != nil {
- return nil, status.Errorf(codes.Internal, "failed to list memos")
+ return nil, status.Errorf(codes.Internal, "failed to list memos: %v", err)
}
location, err := time.LoadLocation(request.Timezone)
@@ -494,12 +494,12 @@ func (s *APIV2Service) ExportMemos(ctx context.Context, request *apiv2pb.ExportM
ExcludeComments: true,
}
if err := s.buildMemoFindWithFilter(ctx, memoFind, request.Filter); err != nil {
- return nil, status.Errorf(codes.Internal, "failed to build find memos with filter")
+ return nil, status.Errorf(codes.Internal, "failed to build find memos with filter: %v", err)
}
memos, err := s.Store.ListMemos(ctx, memoFind)
if err != nil {
- return nil, status.Errorf(codes.Internal, "failed to list memos")
+ return nil, status.Errorf(codes.Internal, "failed to list memos: %v", err)
}
buf := new(bytes.Buffer)