Feature better 404s (#416)

* feature: CSS on actions

* feature: Less crashes when things are not found
This commit is contained in:
James Read 2024-10-02 01:21:37 +02:00 committed by GitHub
parent c0a18f82a5
commit 1d9502d800
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 3 deletions

View File

@ -7,6 +7,8 @@ import (
log "github.com/sirupsen/logrus"
"google.golang.org/genproto/googleapis/api/httpbody"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"errors"
"net"
@ -70,7 +72,7 @@ func (api *oliveTinAPI) StartAction(ctx ctx.Context, req *pb.StartActionRequest)
api.executor.MapActionIdToBindingLock.RUnlock()
if pair == nil || pair.Action == nil {
return nil, errors.New("Action not found")
return nil, status.Errorf(codes.NotFound, "Action not found.")
}
execReq := executor.ExecutionRequest{
@ -153,7 +155,7 @@ func (api *oliveTinAPI) StartActionByGetAndWait(ctx ctx.Context, req *pb.StartAc
LogEntry: internalLogEntryToPb(internalLogEntry),
}, nil
} else {
return nil, errors.New("Execution not found!")
return nil, status.Errorf(codes.NotFound, "Execution not found.")
}
}
@ -211,7 +213,11 @@ func (api *oliveTinAPI) ExecutionStatus(ctx ctx.Context, req *pb.ExecutionStatus
ile = getMostRecentExecutionStatusById(api, req.ActionId)
}
res.LogEntry = internalLogEntryToPb(ile)
if ile == nil {
return nil, status.Errorf(codes.NotFound, "Execution not found.")
} else {
res.LogEntry = internalLogEntryToPb(ile)
}
return res, nil
}

View File

@ -328,6 +328,10 @@ function marshalLink (item, fieldset) {
btn.classList.add('error')
}
if (item.cssClass !== '') {
btn.classList.add(item.cssClass)
}
fieldset.appendChild(btn)
}