Skip to content

Commit

Permalink
re-export ErrorBuilder
Browse files Browse the repository at this point in the history
Signed-off-by: Cassandra Coyle <[email protected]>
  • Loading branch information
cicoyle committed Dec 15, 2023
1 parent 656df7f commit 0901f75
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
22 changes: 11 additions & 11 deletions errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ type Error struct {
}

// ErrorBuilder is used to build the error
type errorBuilder struct {
type ErrorBuilder struct {
err Error
}

Expand Down Expand Up @@ -309,9 +309,9 @@ func (e Error) JSONErrorValue() []byte {
ErrorBuilder
**************************************/

// NewBuilder create a new errorBuilder using the supplied required error fields
func NewBuilder(grpcCode grpcCodes.Code, httpCode int, message string, tag string) *errorBuilder {
return &errorBuilder{
// NewBuilder create a new ErrorBuilder using the supplied required error fields
func NewBuilder(grpcCode grpcCodes.Code, httpCode int, message string, tag string) *ErrorBuilder {
return &ErrorBuilder{
err: Error{
details: make([]proto.Message, 0),
grpcCode: grpcCode,
Expand All @@ -323,7 +323,7 @@ func NewBuilder(grpcCode grpcCodes.Code, httpCode int, message string, tag strin
}

// WithResourceInfo is used to pass ResourceInfo error details to the Error struct.
func (b *errorBuilder) WithResourceInfo(resourceType string, resourceName string, owner string, description string) *errorBuilder {
func (b *ErrorBuilder) WithResourceInfo(resourceType string, resourceName string, owner string, description string) *ErrorBuilder {
resourceInfo := &errdetails.ResourceInfo{
ResourceType: resourceType,
ResourceName: resourceName,
Expand All @@ -337,7 +337,7 @@ func (b *errorBuilder) WithResourceInfo(resourceType string, resourceName string
}

// WithHelpLink is used to pass HelpLink error details to the Error struct.
func (b *errorBuilder) WithHelpLink(url string, description string) *errorBuilder {
func (b *ErrorBuilder) WithHelpLink(url string, description string) *ErrorBuilder {
link := errdetails.Help_Link{
Description: description,
Url: url,
Expand All @@ -352,14 +352,14 @@ func (b *errorBuilder) WithHelpLink(url string, description string) *errorBuilde
}

// WithHelp is used to pass Help error details to the Error struct.
func (b *errorBuilder) WithHelp(links []*errdetails.Help_Link) *errorBuilder {
func (b *ErrorBuilder) WithHelp(links []*errdetails.Help_Link) *ErrorBuilder {
b.err.details = append(b.err.details, &errdetails.Help{Links: links})

return b
}

// WithErrorInfo adds error information to the Error struct.
func (b *errorBuilder) WithErrorInfo(reason string, metadata map[string]string) *errorBuilder {
func (b *ErrorBuilder) WithErrorInfo(reason string, metadata map[string]string) *ErrorBuilder {
errorInfo := &errdetails.ErrorInfo{
Domain: Domain,
Reason: reason,
Expand All @@ -371,7 +371,7 @@ func (b *errorBuilder) WithErrorInfo(reason string, metadata map[string]string)
}

// WithFieldViolation is used to pass FieldViolation error details to the Error struct.
func (b *errorBuilder) WithFieldViolation(fieldName string, msg string) *errorBuilder {
func (b *ErrorBuilder) WithFieldViolation(fieldName string, msg string) *ErrorBuilder {
br := &errdetails.BadRequest{
FieldViolations: []*errdetails.BadRequest_FieldViolation{{
Field: fieldName,
Expand All @@ -385,14 +385,14 @@ func (b *errorBuilder) WithFieldViolation(fieldName string, msg string) *errorBu
}

// WithDetails is used to pass any error details to the Error struct.
func (b *errorBuilder) WithDetails(details ...proto.Message) *errorBuilder {
func (b *ErrorBuilder) WithDetails(details ...proto.Message) *ErrorBuilder {
b.err.details = append(b.err.details, details...)

return b
}

// Build builds our error
func (b *errorBuilder) Build() error {
func (b *ErrorBuilder) Build() error {
// Check for ErrorInfo, since it's required per the proposal
containsErrorInfo := false
for _, detail := range b.err.details {
Expand Down
2 changes: 1 addition & 1 deletion errors/errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func TestError_Error(t *testing.T) {
}
tests := []struct {
name string
builder *errorBuilder
builder *ErrorBuilder
fields fields
want string
}{
Expand Down

0 comments on commit 0901f75

Please sign in to comment.