Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
13 changes: 7 additions & 6 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ import (
type ErrorCode string

const (
InternalError ErrorCode = "Internal Error"
NotFound ErrorCode = "Not Found"
InvalidArgument ErrorCode = "Invalid Argument"
Unauthenticated ErrorCode = "Unauthenticated"
PermissionDenied ErrorCode = "Permission Denied"
Unknown ErrorCode = "Unknown"
InternalError ErrorCode = "Internal Error"
NotFound ErrorCode = "Not Found"
InvalidArgument ErrorCode = "Invalid Argument"
Unauthenticated ErrorCode = "Unauthenticated"
PermissionDenied ErrorCode = "Permission Denied"
UnprocessableContent ErrorCode = "Unprocessable Content"
Unknown ErrorCode = "Unknown"
)

type customError struct {
Expand Down
10 changes: 10 additions & 0 deletions errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@ var _ = Describe("Errors", func() {
Expect(fmt.Sprintf("%+v", errors.StackTrace(err))).To(ContainSubstring("/errors_test.go:"))
})

It("create an unprocessable content error", func() {
msg := "an error with a message"
err := errors.UnprocessableContent.New(msg)

Expect(errors.Code(err)).To(Equal(errors.UnprocessableContent))
Expect(err.Error()).To(Equal(msg))
Expect(errors.DisplayMessage(err)).To(Equal("Unprocessable Content"))
Expect(fmt.Sprintf("%+v", errors.StackTrace(err))).To(ContainSubstring("/errors_test.go:"))
})

It("creates an Unknown error", func() {
msg := "an error with a message"
err := errors.Unknown.New(msg)
Expand Down