Skip to content

Commit

Permalink
check chrome failure type (#678)
Browse files Browse the repository at this point in the history
* check chrome failure type

* avoid unknown

* fix imports
  • Loading branch information
frostbyte73 authored May 17, 2024
1 parent 8fcd028 commit ba221ff
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
4 changes: 4 additions & 0 deletions pkg/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ var (
ErrShuttingDown = psrpc.NewErrorf(psrpc.Unavailable, "server is shutting down")
)

func ErrPageLoadFailed(err string) error {
return psrpc.NewErrorf(psrpc.InvalidArgument, "template page load failed: %s", err)
}

func ErrCouldNotParseConfig(err error) error {
return psrpc.NewErrorf(psrpc.InvalidArgument, "could not parse config: %v", err)
}
Expand Down
7 changes: 4 additions & 3 deletions pkg/info/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ func (e *EgressInfo) SetFailed(err error) {
e.Error = err.Error()
var perr psrpc.Error
if errors.As(err, &perr) {
e.ErrorCode = int32(perr.ToHttp())
} else {
e.ErrorCode = int32(http.StatusInternalServerError)
// unknown is treated the same as an internal error (500)
if !errors.Is(perr.Code(), psrpc.Unknown) {
e.ErrorCode = int32(perr.ToHttp())
}
}
}

Expand Down
10 changes: 8 additions & 2 deletions pkg/pipeline/source/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ import (
const (
startRecordingLog = "START_RECORDING"
endRecordingLog = "END_RECORDING"

chromeFailedToStart = "chrome failed to start:"
)

type WebSource struct {
Expand Down Expand Up @@ -314,11 +316,15 @@ func (s *WebSource) launchChrome(ctx context.Context, p *config.PipelineConfig,
),
)
if err != nil {
return errors.ErrProcessStartFailed(err)
if strings.HasPrefix(err.Error(), chromeFailedToStart) {
return errors.ErrProcessStartFailed(err)
}
errString = err.Error()
}
if errString != "" {
return errors.New(errString)
return errors.ErrPageLoadFailed(errString)
}

return nil
}

Expand Down

0 comments on commit ba221ff

Please sign in to comment.