[lxc-devel] [lxd/master] profiles: don't mask error message when not found

tych0 on Github lxc-bot at linuxcontainers.org
Tue Mar 8 22:34:58 UTC 2016


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 647 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160308/47176761/attachment.bin>
-------------- next part --------------
From 6d4ebed57f6ad23bcb4500746ceb0abf0d642360 Mon Sep 17 00:00:00 2001
From: Tycho Andersen <tycho.andersen at canonical.com>
Date: Tue, 8 Mar 2016 15:32:48 -0700
Subject: [PATCH] profiles: don't mask error message when not found

If we mask this error with the useless "here" prefix, the rest of the error
handling code doesn't figure out that it's a sql.NoRows error, and thus
doesn't propagate the 404 correctly, so we end up with:

$ lxc profile edit host1:invalid
error: here: sql: no rows in result set

Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
---
 lxd/db_profiles.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lxd/db_profiles.go b/lxd/db_profiles.go
index 066c7be..e857b1e 100644
--- a/lxd/db_profiles.go
+++ b/lxd/db_profiles.go
@@ -37,7 +37,7 @@ func dbProfileGet(db *sql.DB, profile string) (int64, *shared.ProfileConfig, err
 	arg2 := []interface{}{&id, &description}
 	err := dbQueryRowScan(db, q, arg1, arg2)
 	if err != nil {
-		return -1, nil, fmt.Errorf("here: %s", err)
+		return -1, nil, err
 	}
 
 	config, err := dbProfileConfig(db, profile)


More information about the lxc-devel mailing list