Skip to content

Commit

Permalink
pkg/config: custom errors (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmank88 authored Jul 26, 2022
1 parent 12caa3c commit 24530b1
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/smartcontractkit/chainlink-relay

go 1.17
go 1.18

require (
github.com/confluentinc/confluent-kafka-go v1.8.2
Expand Down
33 changes: 33 additions & 0 deletions pkg/config/error.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package config

import "fmt"

// lightweight error types copied from core

type ErrInvalid struct {
Name string
Value any
Msg string
}

func (e ErrInvalid) Error() string {
return fmt.Sprintf("%s: invalid value %v: %s", e.Name, e.Value, e.Msg)
}

type ErrMissing struct {
Name string
Msg string
}

func (e ErrMissing) Error() string {
return fmt.Sprintf("%s: missing: %s", e.Name, e.Msg)
}

type ErrEmpty struct {
Name string
Msg string
}

func (e ErrEmpty) Error() string {
return fmt.Sprintf("%s: empty: %s", e.Name, e.Msg)
}

0 comments on commit 24530b1

Please sign in to comment.