Error: Introduce error_copy()

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
diff --git a/error.c b/error.c
index 990050f..d3455ab 100644
--- a/error.c
+++ b/error.c
@@ -43,6 +43,19 @@
     *errp = err;
 }
 
+Error *error_copy(const Error *err)
+{
+    Error *err_new;
+
+    err_new = g_malloc0(sizeof(*err));
+    err_new->msg = g_strdup(err->msg);
+    err_new->fmt = err->fmt;
+    err_new->obj = err->obj;
+    QINCREF(err_new->obj);
+
+    return err_new;
+}
+
 bool error_is_set(Error **errp)
 {
     return (errp && *errp);