mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
This interface allows it to create rich codersdk errors and pass them up to the `wsbuilder` error handling.
24 lines
521 B
Go
24 lines
521 B
Go
package httperror
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
|
|
"github.com/coder/coder/v2/coderd/httpapi"
|
|
"github.com/coder/coder/v2/codersdk"
|
|
)
|
|
|
|
func WriteWorkspaceBuildError(ctx context.Context, rw http.ResponseWriter, err error) {
|
|
if responseErr, ok := IsResponder(err); ok {
|
|
code, resp := responseErr.Response()
|
|
|
|
httpapi.Write(ctx, rw, code, resp)
|
|
return
|
|
}
|
|
|
|
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
|
|
Message: "Internal error creating workspace build.",
|
|
Detail: err.Error(),
|
|
})
|
|
}
|