mirror of
https://github.com/usememos/memos.git
synced 2024-09-20 14:35:54 +08:00
chore: tweak error message
This commit is contained in:
parent
8101a5e0b1
commit
ff81ea602d
|
@ -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,7 +31,6 @@ const (
|
|||
)
|
||||
|
||||
var (
|
||||
profile *_profile.Profile
|
||||
mode string
|
||||
addr string
|
||||
port int
|
||||
|
@ -40,13 +39,14 @@ var (
|
|||
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:
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue