package service_internal import ( "context" "errors" "git.itzana.me/strafesnet/maps-service/pkg/datastore" internal "git.itzana.me/strafesnet/maps-service/pkg/internal" "github.com/nats-io/nats.go" ) type Service struct { DB datastore.Datastore Nats nats.JetStreamContext } // yay duplicate code func (svc *Service) NewError(ctx context.Context, err error) *internal.ErrorStatusCode { status := 500 if errors.Is(err, datastore.ErrNotExist) { status = 404 } return &internal.ErrorStatusCode{ StatusCode: status, Response: internal.Error{ Code: int64(status), Message: err.Error(), }, } }