github.com/sdboyer/gps@v0.16.3/source_errors.go (about)

     1  package gps
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/Masterminds/vcs"
     7  )
     8  
     9  // unwrapVcsErr will extract actual command output from a vcs err, if possible
    10  //
    11  // TODO this is really dumb, lossy, and needs proper handling
    12  func unwrapVcsErr(err error) error {
    13  	switch verr := err.(type) {
    14  	case *vcs.LocalError:
    15  		return fmt.Errorf("%s: %s", verr.Error(), verr.Out())
    16  	case *vcs.RemoteError:
    17  		return fmt.Errorf("%s: %s", verr.Error(), verr.Out())
    18  	default:
    19  		return err
    20  	}
    21  }