change error messages, unexport DataloadersContextKey

This commit is contained in:
Dawid Wysokiński 2020-06-18 13:06:55 +02:00
parent 25e69a54a2
commit 0ece3a49cf
5 changed files with 7 additions and 7 deletions

View File

@ -12,7 +12,7 @@ import (
"github.com/gin-gonic/gin"
)
var DataloadersContextKey ContextKey = "dataloaders"
var dataloadersContextKey ContextKey = "dataloaders"
func DataLoadersToContext(serverRepo server.Repository, cfg dataloaders.Config) gin.HandlerFunc {
return func(c *gin.Context) {
@ -35,11 +35,11 @@ func DataLoadersToContext(serverRepo server.Repository, cfg dataloaders.Config)
}
func StoreDataLoadersInContext(ctx context.Context, loaders map[string]*dataloaders.DataLoaders) context.Context {
return context.WithValue(ctx, DataloadersContextKey, loaders)
return context.WithValue(ctx, dataloadersContextKey, loaders)
}
func DataLoadersFromContext(ctx context.Context) map[string]*dataloaders.DataLoaders {
dl := ctx.Value(DataloadersContextKey)
dl := ctx.Value(dataloadersContextKey)
if dl == nil {
return nil
}

View File

@ -37,7 +37,7 @@ func (ucase *usecase) GetByID(ctx context.Context, server string, id int) (*mode
return nil, err
}
if total == 0 {
return nil, fmt.Errorf("Player with id: %d not found.", id)
return nil, fmt.Errorf("Player (ID: %d) not found.", id)
}
return players[0], nil
}

View File

@ -37,7 +37,7 @@ func (ucase *usecase) GetByKey(ctx context.Context, key string) (*models.Server,
return nil, err
}
if total == 0 {
return nil, fmt.Errorf("Server with key: %s not found.", key)
return nil, fmt.Errorf("Server (key: %s) not found.", key)
}
return servers[0], nil
}

View File

@ -37,7 +37,7 @@ func (ucase *usecase) GetByID(ctx context.Context, server string, id int) (*mode
return nil, err
}
if total == 0 {
return nil, fmt.Errorf("Tribe with id: %d not found.", id)
return nil, fmt.Errorf("Tribe (ID: %s) not found.", id)
}
return tribes[0], nil
}

View File

@ -37,7 +37,7 @@ func (ucase *usecase) GetByID(ctx context.Context, server string, id int) (*mode
return nil, err
}
if total == 0 {
return nil, fmt.Errorf("Village with id: %d not found.", id)
return nil, fmt.Errorf("Village (ID: %d) not found.", id)
}
return villages[0], nil
}