maps-service/pkg/service/service.go
2024-12-02 23:29:13 -08:00

24 lines
534 B
Go

package service
import (
"context"
"git.itzana.me/strafesnet/maps-service/pkg/api"
"git.itzana.me/strafesnet/maps-service/pkg/datastore"
"github.com/nats-io/nats.go"
)
type Service struct {
DB datastore.Datastore
Nats *nats.Conn
}
// NewError creates *ErrorStatusCode from error returned by handler.
//
// Used for common default response.
func (svc *Service) NewError(ctx context.Context, err error) *api.ErrorStatusCode {
return &api.ErrorStatusCode{
StatusCode: 500,
Response: api.Error{Message: err.Error()},
}
}