Skip to content
This repository was archived by the owner on May 15, 2023. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions hermes/probe/probe.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,33 @@ import (
journalpb "github.com/googleinterns/step224-2020/hermes/proto"
)

// ProbeError is an error that includes an exit status for used within Hermes.
type ProbeError struct {
// TODO(evanSpendlove): Refactor metrics.ExitStatus to be named something similar to metrics.APICallStatus.
Status metrics.ExitStatus
Err error
}

// NewProbeError returns a new ProbeError containing the error and status passed.
// Arguments:
// - status: pass the exit status associated with this error.
// - err: the underlying error.
// Returns:
// - ProbeError: returns a new ProbeError object containing the args passed.
func NewProbeError(status metrics.ExitStatus, err error) *ProbeError {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function doesn't do anything.
Just remove it and use &ProbeError{...} in its place.

return &ProbeError{
Status: status,
Err: err,
}
}

// Error returns the error string from the error.
// Returns:
// - string: returns the error as a string.
func (e *ProbeError) Error() string {
return fmt.Sprintf("%v: %v", e.Status, e.Err)
}

// Target holds all of the required information and state for a given target run.
type Target struct {
// Target stores the proto config for the target to be probed.
Expand Down