在因无法读取而移除账户时记录日志

This commit is contained in:
yushijinhun 2018-06-16 20:09:19 +08:00
parent d61006dd67
commit 53cad0e56a
No known key found for this signature in database
GPG Key ID: 5BC167F73EA558E4

View File

@ -52,6 +52,7 @@ import java.util.logging.Level;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static org.jackhuang.hmcl.util.Lang.tryCast; import static org.jackhuang.hmcl.util.Lang.tryCast;
import static org.jackhuang.hmcl.util.Logging.LOG;
public class Settings { public class Settings {
public static final Gson GSON = new GsonBuilder() public static final Gson GSON = new GsonBuilder()
@ -84,7 +85,7 @@ public class Settings {
Map<Object, Object> settings = iterator.next(); Map<Object, Object> settings = iterator.next();
AccountFactory<?> factory = Accounts.ACCOUNT_FACTORY.get(tryCast(settings.get("type"), String.class).orElse("")); AccountFactory<?> factory = Accounts.ACCOUNT_FACTORY.get(tryCast(settings.get("type"), String.class).orElse(""));
if (factory == null) { if (factory == null) {
// unrecognized account type, so remove it. LOG.warning("Unrecognized account type, removing: " + settings);
iterator.remove(); iterator.remove();
continue; continue;
} }
@ -93,7 +94,7 @@ public class Settings {
try { try {
account = factory.fromStorage(settings, getProxy()); account = factory.fromStorage(settings, getProxy());
} catch (Exception e) { } catch (Exception e) {
// storage is malformed, delete. LOG.log(Level.WARNING, "Malformed account storage, removing: " + settings, e);
iterator.remove(); iterator.remove();
continue; continue;
} }