do not show details for unknown error

This commit is contained in:
guinux 2016-08-24 17:19:14 +02:00
parent ab3a6c074e
commit a15669fdf4

View File

@ -310,7 +310,9 @@ namespace Pamac {
Alpm.Errno errno = alpm_handle.errno (); Alpm.Errno errno = alpm_handle.errno ();
current_error.errno = (uint) errno; current_error.errno = (uint) errno;
current_error.message = _("Failed to synchronize any databases"); current_error.message = _("Failed to synchronize any databases");
current_error.details = { Alpm.strerror (errno) }; if (errno != 0) {
current_error.details = { Alpm.strerror (errno) };
}
refresh_finished (false); refresh_finished (false);
} else { } else {
refresh_finished (true); refresh_finished (true);
@ -1212,7 +1214,9 @@ namespace Pamac {
Alpm.Errno errno = alpm_handle.errno (); Alpm.Errno errno = alpm_handle.errno ();
current_error.errno = (uint) errno; current_error.errno = (uint) errno;
current_error.message = _("Failed to init transaction"); current_error.message = _("Failed to init transaction");
current_error.details = { Alpm.strerror (errno) }; if (errno != 0) {
current_error.details = { Alpm.strerror (errno) };
}
return false; return false;
} else { } else {
intern_lock = true; intern_lock = true;
@ -1226,7 +1230,9 @@ namespace Pamac {
Alpm.Errno errno = alpm_handle.errno (); Alpm.Errno errno = alpm_handle.errno ();
current_error.errno = (uint) errno; current_error.errno = (uint) errno;
current_error.message = _("Failed to prepare transaction"); current_error.message = _("Failed to prepare transaction");
current_error.details = { Alpm.strerror (errno) }; if (errno != 0) {
current_error.details = { Alpm.strerror (errno) };
}
return false; return false;
} }
return true; return true;
@ -1242,7 +1248,9 @@ namespace Pamac {
} else { } else {
current_error.errno = (uint) errno; current_error.errno = (uint) errno;
current_error.message = _("Failed to prepare transaction"); current_error.message = _("Failed to prepare transaction");
current_error.details = { "%s: %s".printf (pkg.name, Alpm.strerror (errno)) }; if (errno != 0) {
current_error.details = { "%s: %s".printf (pkg.name, Alpm.strerror (errno)) };
}
return false; return false;
} }
} }
@ -1313,13 +1321,17 @@ namespace Pamac {
Alpm.Errno errno = alpm_handle.errno (); Alpm.Errno errno = alpm_handle.errno ();
current_error.errno = (uint) errno; current_error.errno = (uint) errno;
current_error.message = _("Failed to prepare transaction"); current_error.message = _("Failed to prepare transaction");
current_error.details = { "%s: %s".printf (pkgpath, Alpm.strerror (errno)) }; if (errno != 0) {
current_error.details = { "%s: %s".printf (pkgpath, Alpm.strerror (errno)) };
}
return false; return false;
} else if (alpm_handle.trans_add_pkg (pkg) == -1) { } else if (alpm_handle.trans_add_pkg (pkg) == -1) {
Alpm.Errno errno = alpm_handle.errno (); Alpm.Errno errno = alpm_handle.errno ();
current_error.errno = (uint) errno; current_error.errno = (uint) errno;
current_error.message = _("Failed to prepare transaction"); current_error.message = _("Failed to prepare transaction");
current_error.details = { "%s: %s".printf (pkg->name, Alpm.strerror (errno)) }; if (errno != 0) {
current_error.details = { "%s: %s".printf (pkg->name, Alpm.strerror (errno)) };
}
// free the package because it will not be used // free the package because it will not be used
delete pkg; delete pkg;
return false; return false;
@ -1338,7 +1350,9 @@ namespace Pamac {
Alpm.Errno errno = alpm_handle.errno (); Alpm.Errno errno = alpm_handle.errno ();
current_error.errno = (uint) errno; current_error.errno = (uint) errno;
current_error.message = _("Failed to prepare transaction"); current_error.message = _("Failed to prepare transaction");
current_error.details = { "%s: %s".printf (pkg.name, Alpm.strerror (errno)) }; if (errno != 0) {
current_error.details = { "%s: %s".printf (pkg.name, Alpm.strerror (errno)) };
}
return false; return false;
} }
return true; return true;
@ -1352,11 +1366,11 @@ namespace Pamac {
Alpm.Errno errno = alpm_handle.errno (); Alpm.Errno errno = alpm_handle.errno ();
current_error.errno = (uint) errno; current_error.errno = (uint) errno;
current_error.message = _("Failed to prepare transaction"); current_error.message = _("Failed to prepare transaction");
string detail = Alpm.strerror (errno);
switch (errno) { switch (errno) {
case 0:
break;
case Alpm.Errno.PKG_INVALID_ARCH: case Alpm.Errno.PKG_INVALID_ARCH:
detail += ":"; details += Alpm.strerror (errno) + ":";
details += (owned) detail;
unowned Alpm.List<string*> list = err_data; unowned Alpm.List<string*> list = err_data;
while (list != null) { while (list != null) {
string* pkgname = list.data; string* pkgname = list.data;
@ -1366,8 +1380,7 @@ namespace Pamac {
} }
break; break;
case Alpm.Errno.UNSATISFIED_DEPS: case Alpm.Errno.UNSATISFIED_DEPS:
detail += ":"; details += Alpm.strerror (errno) + ":";
details += (owned) detail;
unowned Alpm.List<Alpm.DepMissing*> list = err_data; unowned Alpm.List<Alpm.DepMissing*> list = err_data;
while (list != null) { while (list != null) {
Alpm.DepMissing* miss = list.data; Alpm.DepMissing* miss = list.data;
@ -1377,8 +1390,7 @@ namespace Pamac {
} }
break; break;
case Alpm.Errno.CONFLICTING_DEPS: case Alpm.Errno.CONFLICTING_DEPS:
detail += ":"; details += Alpm.strerror (errno) + ":";
details += (owned) detail;
unowned Alpm.List<Alpm.Conflict*> list = err_data; unowned Alpm.List<Alpm.Conflict*> list = err_data;
while (list != null) { while (list != null) {
Alpm.Conflict* conflict = list.data; Alpm.Conflict* conflict = list.data;
@ -1393,7 +1405,7 @@ namespace Pamac {
} }
break; break;
default: default:
details += (owned) detail; details += Alpm.strerror (errno);
break; break;
} }
current_error.details = (owned) details; current_error.details = (owned) details;
@ -1507,12 +1519,12 @@ namespace Pamac {
return; return;
} }
current_error.message = _("Failed to commit transaction"); current_error.message = _("Failed to commit transaction");
string detail = Alpm.strerror (errno);
string[] details = {}; string[] details = {};
switch (errno) { switch (errno) {
case 0:
break;
case Alpm.Errno.FILE_CONFLICTS: case Alpm.Errno.FILE_CONFLICTS:
detail += ":"; details += Alpm.strerror (errno) + ":";
details += (owned) detail;
//TransFlag flags = alpm_handle.trans_get_flags (); //TransFlag flags = alpm_handle.trans_get_flags ();
//if ((flags & TransFlag.FORCE) != 0) { //if ((flags & TransFlag.FORCE) != 0) {
//details += _("unable to %s directory-file conflicts").printf ("--force"); //details += _("unable to %s directory-file conflicts").printf ("--force");
@ -1536,8 +1548,7 @@ namespace Pamac {
case Alpm.Errno.PKG_INVALID_CHECKSUM: case Alpm.Errno.PKG_INVALID_CHECKSUM:
case Alpm.Errno.PKG_INVALID_SIG: case Alpm.Errno.PKG_INVALID_SIG:
case Alpm.Errno.DLT_INVALID: case Alpm.Errno.DLT_INVALID:
detail += ":"; details += Alpm.strerror (errno) + ":";
details += (owned) detail;
unowned Alpm.List<string*> list = err_data; unowned Alpm.List<string*> list = err_data;
while (list != null) { while (list != null) {
string* filename = list.data; string* filename = list.data;
@ -1547,7 +1558,7 @@ namespace Pamac {
} }
break; break;
default: default:
details += (owned) detail; details += Alpm.strerror (errno);
break; break;
} }
current_error.details = (owned) details; current_error.details = (owned) details;