Skip to content

Instantly share code, notes, and snippets.

@AntonStoeckl
Last active May 4, 2020 13:49
Show Gist options
  • Save AntonStoeckl/9950def38ea8e8bcefcf4ce753467ffb to your computer and use it in GitHub Desktop.
Save AntonStoeckl/9950def38ea8e8bcefcf4ce753467ffb to your computer and use it in GitHub Desktop.
Example for my iDDD with Go blog article series at https://medium.com/@TonyBologni
package shared
import "github.com/cockroachdb/errors"
var (
ErrInputIsInvalid = errors.New("input is invalid")
ErrNotFound = errors.New("not found")
ErrDuplicate = errors.New("duplicate")
ErrDomainConstraintsViolation = errors.New("domain constraints violation")
ErrMaxRetriesExceeded = errors.New("max retries exceeded")
ErrConcurrencyConflict = errors.New("concurrency conflict")
ErrMarshalingFailed = errors.New("marshaling failed")
ErrUnmarshalingFailed = errors.New("unmarshaling failed")
ErrTechnical = errors.New("technical")
)
func MarkAndWrapError(original error, markAs error, wrapWith string) error {
return errors.Mark(errors.Wrap(original, wrapWith), markAs)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment