porting all github actions from bluesky-social/indigo to tangled CI

fix double error rendering

Changed files
+12 -3
cmd
astrolabe
+1 -1
cmd/astrolabe/handlers.go
··· 212 212 } 213 213 resp, err := RepoGetRecord(ctx, &xrpcc, "", collection.String(), ident.DID.String(), rkey.String()) 214 214 if err != nil { 215 - return err 215 + return echo.NewHTTPError(400, fmt.Sprintf("failed to load record: %s", err)) 216 216 } 217 217 218 218 if nil == resp.Value {
+8 -2
cmd/astrolabe/service.go
··· 4 4 "context" 5 5 "embed" 6 6 "errors" 7 + "fmt" 7 8 "io/fs" 8 9 "net/http" 9 10 "os" ··· 142 143 143 144 func (srv *Server) errorHandler(err error, c echo.Context) { 144 145 code := http.StatusInternalServerError 146 + var errorMessage string 145 147 if he, ok := err.(*echo.HTTPError); ok { 146 148 code = he.Code 149 + errorMessage = fmt.Sprintf("%s", he.Message) 147 150 } 148 151 if code >= 500 { 149 152 slog.Warn("astrolabe-http-internal-error", "err", err) 150 153 } 151 154 data := pongo2.Context{ 152 - "statusCode": code, 155 + "statusCode": code, 156 + "errorMessage": errorMessage, 157 + } 158 + if !c.Response().Committed { 159 + c.Render(code, "error.html", data) 153 160 } 154 - c.Render(code, "error.html", data) 155 161 } 156 162 157 163 func (srv *Server) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
+3
cmd/astrolabe/templates/error.html
··· 7 7 <center> 8 8 <h1 style="font-size: 8em;">{{ statusCode }}</h1> 9 9 <h2 style="font-size: 3em;">Error!</h2> 10 + {% if errorMessage %} 11 + <p><code>{{ errorMessage }}</code></p> 12 + {% endif %} 10 13 </center> 11 14 {% endblock %}