resources: Update constructor signature to return error as well

Update the helper functions so they're easier to properly use!
This commit is contained in:
James Shubin
2016-10-23 01:26:35 -04:00
parent e06c4a873d
commit fb9449038b
9 changed files with 117 additions and 116 deletions

View File

@@ -54,7 +54,7 @@ type MsgUID struct {
}
// NewMsgRes is a constructor for this resource.
func NewMsgRes(name, body, priority string, journal, syslog bool, fields map[string]string) *MsgRes {
func NewMsgRes(name, body, priority string, journal, syslog bool, fields map[string]string) (*MsgRes, error) {
message := name
if body != "" {
message = body
@@ -71,8 +71,7 @@ func NewMsgRes(name, body, priority string, journal, syslog bool, fields map[str
Syslog: syslog,
}
obj.Init()
return obj
return obj, obj.Init()
}
// Init runs some startup code for this resource.