Skip to content

Commit

Permalink
fix(lokihandler): properly handle unsupported error
Browse files Browse the repository at this point in the history
  • Loading branch information
tdakkota committed Apr 12, 2024
1 parent 6da1105 commit 2c14d78
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion internal/lokihandler/lokihandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

"github.com/go-faster/oteldb/internal/iterators"
"github.com/go-faster/oteldb/internal/logql/logqlengine"
"github.com/go-faster/oteldb/internal/logql/logqlengine/logqlerrors"
"github.com/go-faster/oteldb/internal/logstorage"
"github.com/go-faster/oteldb/internal/lokiapi"
"github.com/go-faster/oteldb/internal/otelstorage"
Expand Down Expand Up @@ -273,8 +274,12 @@ func (h *LokiAPI) Series(ctx context.Context, params lokiapi.SeriesParams) (*lok
//
// Used for common default response.
func (h *LokiAPI) NewError(_ context.Context, err error) *lokiapi.ErrorStatusCode {
code := http.StatusBadRequest
if _, ok := errors.Into[*logqlerrors.UnsupportedError](err); ok {
code = http.StatusNotImplemented
}
return &lokiapi.ErrorStatusCode{
StatusCode: http.StatusBadRequest,
StatusCode: code,
Response: lokiapi.Error(err.Error()),
}
}

0 comments on commit 2c14d78

Please sign in to comment.