Probe revamped to provide for a new WrappedError struct to wrap probes as error interface

This convenience was necessary to be used for golang library functions like io.Copy and io.Pipe
where we shouldn't be writing proxies and alternatives returning *probe.Error

This change also brings more changes across code base for clear separation regarding where an error
interface should be passed encapsulating *probe.Error and where it should be used as is.
This commit is contained in:
Harshavardhana
2015-08-07 23:47:22 -07:00
parent 28d9565400
commit 45b59b8456
34 changed files with 392 additions and 363 deletions

View File

@@ -49,7 +49,7 @@ func getAuth(reply *AuthReply) *probe.Error {
// Get auth keys
func (s *AuthService) Get(r *http.Request, args *Args, reply *AuthReply) error {
if err := getAuth(reply); err != nil {
return err
return probe.NewWrappedError(err)
}
return nil
}

View File

@@ -56,5 +56,8 @@ func setDonut(args *DonutArgs, reply *Reply) *probe.Error {
// Set method
func (s *DonutService) Set(r *http.Request, args *DonutArgs, reply *Reply) error {
return setDonut(args, reply)
if err := setDonut(args, reply); err != nil {
return probe.NewWrappedError(err)
}
return nil
}

View File

@@ -55,7 +55,7 @@ func setSysInfoReply(sis *SysInfoReply) *probe.Error {
var err error
sis.Hostname, err = os.Hostname()
if err != nil {
return probe.New(err)
return probe.NewError(err)
}
return nil
}
@@ -70,7 +70,7 @@ func setMemStatsReply(sis *MemStatsReply) *probe.Error {
// Get method
func (s *SysInfoService) Get(r *http.Request, args *Args, reply *SysInfoReply) error {
if err := setSysInfoReply(reply); err != nil {
return err
return probe.NewWrappedError(err)
}
return nil
}
@@ -78,7 +78,7 @@ func (s *SysInfoService) Get(r *http.Request, args *Args, reply *SysInfoReply) e
// Get method
func (s *MemStatsService) Get(r *http.Request, args *Args, reply *MemStatsReply) error {
if err := setMemStatsReply(reply); err != nil {
return err
return probe.NewWrappedError(err)
}
return nil
}