From 6ca55e2bdd151acace0c0f5d7c626d26e58d65f0 Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Fri, 3 Jan 2014 15:52:52 -0500 Subject: tools/migration/migrator/prosody_files: Fix undefined global access of ?error?, print the actual error message and correct file path in the error message when we fail to load a file, skip broken files instead of failing migration. --- tools/migration/migrator/prosody_files.lua | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'tools/migration/migrator') diff --git a/tools/migration/migrator/prosody_files.lua b/tools/migration/migrator/prosody_files.lua index 4462fb3e..c9367d9c 100644 --- a/tools/migration/migrator/prosody_files.lua +++ b/tools/migration/migrator/prosody_files.lua @@ -13,6 +13,7 @@ local next = next; local pairs = pairs; local json = require "util.json"; local os_getenv = os.getenv; +local error = error; prosody = {}; local dm = require "util.datamanager" @@ -95,15 +96,18 @@ function reader(input) local iter = mtools.sorted { reader = function() local x = iter(); - if x then + while x do dm.set_data_path(path); local err; x.data, err = dm.load(x.user, x.host, x.store); if x.data == nil and err then - error(("Error loading data at path %s for %s@%s (%s store)") - :format(path, x.user or "", x.host or "", x.store or ""), 0); + local p = dm.getpath(x.user, x.host, x.store); + print(("Error loading data at path %s for %s@%s (%s store): %s") + :format(p, x.user or "", x.host or "", x.store or "", err or "")); + else + return x; end - return x; + x = iter(); end end; sorter = function(a, b) -- cgit v1.2.3