Return error rather than empty entities
authorMikael Berthe <mikael@lilotux.net>
Thu, 13 Apr 2017 09:30:47 +0200
changeset 99 6ec2a44a1bd1
parent 98 5d803adfc57e
child 100 e327896577dd
Return error rather than empty entities
gondole.go
notifications.go
--- a/gondole.go	Thu Apr 13 00:17:57 2017 +0200
+++ b/gondole.go	Thu Apr 13 09:30:47 2017 +0200
@@ -19,8 +19,10 @@
 	NoRedirect = "urn:ietf:wg:oauth:2.0:oob"
 )
 
+// Error codes
 var (
-	ErrAlreadyRegistered = errors.New("App already registered")
+	ErrAlreadyRegistered = errors.New("app already registered")
+	ErrEntityNotFound    = errors.New("entity not found")
 )
 
 // prepareRequest insert all pre-defined stuff
--- a/notifications.go	Thu Apr 13 00:17:57 2017 +0200
+++ b/notifications.go	Thu Apr 13 09:30:47 2017 +0200
@@ -51,6 +51,10 @@
 		return &notification, fmt.Errorf("notification API: %s", err.Error())
 	}
 
+	if notification.ID == 0 {
+		return nil, ErrEntityNotFound
+	}
+
 	return &notification, nil
 }