Skip to content

Commit

Permalink
check chrome failure type
Browse files Browse the repository at this point in the history
  • Loading branch information
frostbyte73 committed May 16, 2024
1 parent 8fcd028 commit 3b2fc78
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 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
2 changes: 0 additions & 2 deletions pkg/info/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ func (e *EgressInfo) SetFailed(err error) {
var perr psrpc.Error
if errors.As(err, &perr) {
e.ErrorCode = int32(perr.ToHttp())
} else {
e.ErrorCode = int32(http.StatusInternalServerError)
}
}

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 3b2fc78

Please sign in to comment.