mirror of
https://github.com/google/glazier.git
synced 2025-12-25 03:02:01 -05:00
Allow ExecError to wrap other errors. Wrap ErrTimeout during timeout failures.
PiperOrigin-RevId: 507456687
This commit is contained in:
committed by
Copybara-Service
parent
a65510befb
commit
327255c518
@@ -38,6 +38,7 @@ type ExecResult struct {
|
||||
type ExecError struct {
|
||||
errmsg string
|
||||
procresult ExecResult
|
||||
wraps error
|
||||
}
|
||||
|
||||
// ExecConfig provides flexible execution configuration.
|
||||
@@ -85,6 +86,8 @@ func (e ExecError) Error() string {
|
||||
return e.errmsg
|
||||
}
|
||||
|
||||
func (e ExecError) Unwrap() error { return e.wraps }
|
||||
|
||||
// Result returns any information that could be captured from the subprocess that was executed.
|
||||
func (e ExecError) Result() ExecResult {
|
||||
return e.procresult
|
||||
|
||||
@@ -205,9 +205,10 @@ func execute(path string, args []string, conf *ExecConfig) (ExecResult, error) {
|
||||
|
||||
// when the execution times out return a timeout error
|
||||
if conf.Timeout != nil && !timer.Stop() {
|
||||
return result, &ExecError{
|
||||
return result, ExecError{
|
||||
errmsg: ErrTimeout.Error(),
|
||||
procresult: result,
|
||||
wraps: ErrTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user