The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/3503

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
Closes #3502

Signed-off-by: Stéphane Graber <[email protected]>
From 0c1a8baecf6068cdcb5ec9f1147a5ad69fbfa4de Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <[email protected]>
Date: Thu, 6 Jul 2017 16:19:08 -0400
Subject: [PATCH] shared: Use custom error type for RunCommand
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Closes #3502

Signed-off-by: Stéphane Graber <[email protected]>
---
 shared/util.go | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/shared/util.go b/shared/util.go
index 21648147f..44a33c02a 100644
--- a/shared/util.go
+++ b/shared/util.go
@@ -775,10 +775,23 @@ func RemoveDuplicatesFromString(s string, sep string) 
string {
        return s
 }
 
+type RunError struct {
+       msg string
+       Err error
+}
+
+func (e RunError) Error() string {
+       return e.msg
+}
+
 func RunCommand(name string, arg ...string) (string, error) {
        output, err := exec.Command(name, arg...).CombinedOutput()
        if err != nil {
-               return string(output), fmt.Errorf("Failed to run: %s %s: %s", 
name, strings.Join(arg, " "), strings.TrimSpace(string(output)))
+               err := RunError{
+                       msg: fmt.Sprintf("Failed to run: %s %s: %s", name, 
strings.Join(arg, " "), strings.TrimSpace(string(output))),
+                       Err: err,
+               }
+               return string(output), err
        }
 
        return string(output), nil
_______________________________________________
lxc-devel mailing list
[email protected]
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to