Skip to content

Commit

Permalink
feat(gerr): expose Code/Message getter (#6)
Browse files Browse the repository at this point in the history
use getter insteal of access by array first item
  • Loading branch information
cage1016 authored and cutedogspark committed Apr 17, 2018
1 parent 404b1fc commit e92ae8d
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions gerr.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,22 @@ func (c *GErrors) AppendDomain(domain string) *GErrors {
return c
}

func (c GErrors) Empty() bool {
return len(c) == 0
func (c *GErrors) Empty() bool {
return len(*c) == 0
}

func (c *GErrors) Code() uint {
if c.Empty() {
return 0
}
return (*c)[0].Code
}

func (c *GErrors) Message() string {
if c.Empty() {
return ""
}
return (*c)[0].Message
}

func NewGErrors() *GErrors { return &GErrors{} }

0 comments on commit e92ae8d

Please sign in to comment.