[yast-commit] r40286 - in /trunk/pkg-bindings: package/yast2-pkg-bindings.changes src/Package.cc src/PkgModuleFunctions.cc src/PkgModuleFunctions.h src/Source.cc src/Target.cc
![](https://seccdn.libravatar.org/avatar/c3c40c0a8c67869856fd7e06cbcb4099.jpg?s=120&d=mm&r=g)
Author: lslezak Date: Wed Aug 15 13:52:36 2007 New Revision: 40286 URL: http://svn.opensuse.org/viewcvs/yast?rev=40286&view=rev Log: - return history of exceptions in Pkg::LastError() result (#299716) Modified: trunk/pkg-bindings/package/yast2-pkg-bindings.changes trunk/pkg-bindings/src/Package.cc trunk/pkg-bindings/src/PkgModuleFunctions.cc trunk/pkg-bindings/src/PkgModuleFunctions.h trunk/pkg-bindings/src/Source.cc trunk/pkg-bindings/src/Target.cc Modified: trunk/pkg-bindings/package/yast2-pkg-bindings.changes URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/package/yast2-pkg-bindings.changes?rev=40286&r1=40285&r2=40286&view=diff ============================================================================== --- trunk/pkg-bindings/package/yast2-pkg-bindings.changes (original) +++ trunk/pkg-bindings/package/yast2-pkg-bindings.changes Wed Aug 15 13:52:36 2007 @@ -1,4 +1,9 @@ ------------------------------------------------------------------- +Wed Aug 15 13:51:11 CEST 2007 - lslezak@suse.cz + +- return history of exceptions in Pkg::LastError() result (#299716) + +------------------------------------------------------------------- Thu Aug 9 10:20:08 CEST 2007 - lslezak@suse.cz - Pkg::SourceScan(), Pkg::SourceCreate() - use product name or URL Modified: trunk/pkg-bindings/src/Package.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/src/Package.cc?rev=40286&r1=40285&r2=40286&view=diff ============================================================================== --- trunk/pkg-bindings/src/Package.cc (original) +++ trunk/pkg-bindings/src/Package.cc Wed Aug 15 13:52:36 2007 @@ -2152,7 +2152,7 @@ catch (const zypp::Exception& excpt) { y2error("An error occurred during Pkg::PkgSolveCheckTargetOnly"); - _last_error.setLastError(excpt.asUserString()); + _last_error.setLastError(ExceptionAsString(excpt)); } return YCPBoolean(result); @@ -2229,7 +2229,7 @@ catch (const zypp::Exception& excpt) { y2error("Pkg::Commit has failed: ZYpp::commit has failed"); - _last_error.setLastError(excpt.asUserString()); + _last_error.setLastError(ExceptionAsString(excpt)); return YCPVoid(); } Modified: trunk/pkg-bindings/src/PkgModuleFunctions.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/src/PkgModuleFunctions.cc?rev=40286&r1=40285&r2=40286&view=diff ============================================================================== --- trunk/pkg-bindings/src/PkgModuleFunctions.cc (original) +++ trunk/pkg-bindings/src/PkgModuleFunctions.cc Wed Aug 15 13:52:36 2007 @@ -635,6 +635,22 @@ return zypp::RepoManager(repo_options); } +// convert Exception object to string represenatation +std::string PkgModuleFunctions::ExceptionAsString(const zypp::Exception &e) +{ + std::string ret = e.asUserString(); + + if (e.historySize() > 0) + { + ret += "\n" + e.historyAsString(); + } + + y2debug("Error message: %s", ret.c_str()); + + return ret; +} + + /** ------------------------ * Convert InstSrcDescr to product info YCPMap: * <TABLE> Modified: trunk/pkg-bindings/src/PkgModuleFunctions.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/src/PkgModuleFunctions.h?rev=40286&r1=40285&r2=40286&view=diff ============================================================================== --- trunk/pkg-bindings/src/PkgModuleFunctions.h (original) +++ trunk/pkg-bindings/src/PkgModuleFunctions.h Wed Aug 15 13:52:36 2007 @@ -178,6 +178,9 @@ zypp::Url shortenUrl(const zypp::Url &url); + // convert Exception to string represenatation + std::string ExceptionAsString(const zypp::Exception &e); + private: /** Modified: trunk/pkg-bindings/src/Source.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/src/Source.cc?rev=40286&r1=40285&r2=40286&view=diff ============================================================================== --- trunk/pkg-bindings/src/Source.cc (original) +++ trunk/pkg-bindings/src/Source.cc Wed Aug 15 13:52:36 2007 @@ -363,7 +363,7 @@ { // FIXME: assuming the sources are already initialized y2error ("Error in SourceRestore: %s", excpt.asString().c_str()); - _last_error.setLastError(excpt.asUserString()); + _last_error.setLastError(ExceptionAsString(excpt)); success = false; } @@ -422,7 +422,7 @@ { // FIXME: assuming the sources are already initialized y2error ("Error in SourceLoad: %s", excpt.asString().c_str()); - _last_error.setLastError(excpt.asUserString()); + _last_error.setLastError(ExceptionAsString(excpt)); success = false; } } @@ -502,7 +502,7 @@ catch (const zypp::Exception& excpt) { y2error ("Error in SourceStartCache: %s", excpt.asString().c_str()); - _last_error.setLastError(excpt.asUserString()); + _last_error.setLastError(ExceptionAsString(excpt)); } // catch an exception from boost (e.g. a file cannot be read by non-root user) catch (const std::exception& err) @@ -660,7 +660,7 @@ catch (const zypp::Exception & excpt) { y2error("Pkg::SourceSaveAll has failed: %s", excpt.msg().c_str() ); - _last_error.setLastError(excpt.asUserString()); + _last_error.setLastError(ExceptionAsString(excpt)); return YCPBoolean(false); } } @@ -693,7 +693,7 @@ catch (zypp::Exception & excpt) { y2error("Pkg::SourceSaveAll has failed: %s", excpt.msg().c_str() ); - _last_error.setLastError(excpt.asUserString()); + _last_error.setLastError(ExceptionAsString(excpt)); return YCPBoolean(false); } } @@ -748,7 +748,7 @@ catch (zypp::Exception & excpt) { y2error("Pkg::SourceFinishAll has failed: %s", excpt.msg().c_str() ); - _last_error.setLastError(excpt.asUserString()); + _last_error.setLastError(ExceptionAsString(excpt)); return YCPBoolean(false); } @@ -1033,7 +1033,7 @@ if (!optional->value()) { - _last_error.setLastError(excpt.asUserString()); + _last_error.setLastError(ExceptionAsString(excpt)); y2milestone("File not found: %s", f->value_cstr()); } } @@ -1157,7 +1157,7 @@ } catch (const zypp::Exception& excpt) { - _last_error.setLastError(excpt.asUserString()); + _last_error.setLastError(ExceptionAsString(excpt)); y2milestone ("Directory not found: %s", d->value_cstr()); found = false; } @@ -1215,7 +1215,7 @@ } catch (const zypp::Exception & excpt) { - _last_error.setLastError(excpt.asUserString()); + _last_error.setLastError(ExceptionAsString(excpt)); y2error ("Cannot set the new URL for source %s (%lld): %s", repo->repoInfo().alias().c_str(), id->asInteger()->value(), excpt.msg().c_str()); return YCPBoolean(false); @@ -1672,7 +1672,7 @@ catch(const zypp::Exception & expt) { y2error("Invalid URL: %s", expt.asString().c_str()); - _last_error.setLastError(expt.asUserString()); + _last_error.setLastError(ExceptionAsString(expt)); return YCPVoid(); } @@ -1717,7 +1717,7 @@ catch (zypp::repo::RepoUnknownTypeException &e) { ycperror("Unknown source type '%s': %s", type.c_str(), e.asString().c_str()); - _last_error.setLastError(e.asUserString()); + _last_error.setLastError(ExceptionAsString(e)); return YCPVoid(); } @@ -1783,7 +1783,7 @@ catch(const zypp::Exception & expt ) { y2error ("Invalid URL: %s", expt.asString().c_str()); - _last_error.setLastError(expt.asUserString()); + _last_error.setLastError(ExceptionAsString(expt)); return YCPList(); } @@ -1807,7 +1807,7 @@ { y2error("Scanning products for '%s' has failed" , url.asString().c_str()); - _last_error.setLastError(excpt.asUserString()); + _last_error.setLastError(ExceptionAsString(excpt)); return ids; } @@ -1831,7 +1831,7 @@ { y2error("SourceScan for '%s' product '%s' has failed" , url.asString().c_str(), pn.asString().c_str()); - _last_error.setLastError(excpt.asUserString()); + _last_error.setLastError(ExceptionAsString(excpt)); } } } else { @@ -1846,7 +1846,7 @@ { y2error("SourceScan for '%s' product '%s' has failed" , url.asString().c_str(), pn.asString().c_str()); - _last_error.setLastError(excpt.asUserString()); + _last_error.setLastError(ExceptionAsString(excpt)); } } @@ -1918,7 +1918,7 @@ catch(const zypp::Exception & expt ) { y2error ("Invalid URL: %s", expt.asString().c_str()); - _last_error.setLastError(expt.asUserString()); + _last_error.setLastError(ExceptionAsString(expt)); return YCPInteger (-1LL); } @@ -1938,7 +1938,7 @@ } catch ( const zypp::Exception& excpt) { - _last_error.setLastError(excpt.asUserString()); + _last_error.setLastError(ExceptionAsString(excpt)); y2error( "Cannot read the product list from the media" ); return YCPInteger(ret); } @@ -1968,7 +1968,7 @@ { y2error("SourceCreate for '%s' product '%s' has failed" , url.asString().c_str(), pn.asString().c_str()); - _last_error.setLastError(excpt.asUserString()); + _last_error.setLastError(ExceptionAsString(excpt)); return YCPInteger(-1LL); } } @@ -1988,7 +1988,7 @@ { y2error("SourceCreate for '%s' product '%s' has failed" , url.asString().c_str(), pn.asString().c_str()); - _last_error.setLastError(excpt.asUserString()); + _last_error.setLastError(ExceptionAsString(excpt)); } } @@ -2046,7 +2046,7 @@ { std::string alias = repo->repoInfo().alias(); y2error ("Error for '%s': %s", alias.c_str(), excpt.asString().c_str()); - _last_error.setLastError(alias + ": " + excpt.asUserString()); + _last_error.setLastError(alias + ": " + ExceptionAsString(excpt)); success = false; } @@ -2157,7 +2157,7 @@ { std::string alias = repo->repoInfo().alias(); y2error ("Error for '%s': %s", alias.c_str(), excpt.asString().c_str()); - _last_error.setLastError(alias + ": " + excpt.asUserString()); + _last_error.setLastError(alias + ": " + ExceptionAsString(excpt)); success = false; } @@ -2388,7 +2388,7 @@ } catch (zypp::Exception & excpt) { - _last_error.setLastError(excpt.asUserString()); + _last_error.setLastError(ExceptionAsString(excpt)); y2error("Pkg::SourceMoveDownloadArea has failed: %s", excpt.msg().c_str()); return YCPBoolean(false); } @@ -2478,7 +2478,7 @@ { std::string alias = repoinfo.alias(); y2error ("Resolvables from '%s' havn't been loaded: %s", alias.c_str(), excpt.asString().c_str()); - _last_error.setLastError("'" + alias + "': " + excpt.asUserString()); + _last_error.setLastError("'" + alias + "': " + ExceptionAsString(excpt)); success = false; // FIXME ?? @@ -2495,7 +2495,7 @@ } unsigned int size_end = zypp_ptr()->pool().size(); - y2milestone("Pool size at end: %d (loaded %d resolvables)", size_end, size_start - size_end); + y2milestone("Pool size at end: %d (loaded %d resolvables)", size_end, size_end - size_start); return success; } @@ -2547,7 +2547,7 @@ } catch (const zypp::Exception& excpt) { - _last_error.setLastError(excpt.asUserString()); + _last_error.setLastError(ExceptionAsString(excpt)); y2error( "Cannot detect the repository type" ); return YCPVoid(); } @@ -2577,7 +2577,7 @@ } catch ( const zypp::Exception& excpt) { - _last_error.setLastError(excpt.asUserString()); + _last_error.setLastError(ExceptionAsString(excpt)); y2error( "Cannot read the product list from the media" ); return YCPList(); } Modified: trunk/pkg-bindings/src/Target.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/src/Target.cc?rev=40286&r1=40285&r2=40286&view=diff ============================================================================== --- trunk/pkg-bindings/src/Target.cc (original) +++ trunk/pkg-bindings/src/Target.cc Wed Aug 15 13:52:36 2007 @@ -64,7 +64,7 @@ } catch (zypp::Exception & excpt) { - _last_error.setLastError(excpt.asUserString()); + _last_error.setLastError(ExceptionAsString(excpt)); ycperror("TargetInit has failed: %s", excpt.msg().c_str() ); return YCPError(excpt.msg().c_str(), YCPBoolean(false)); } @@ -92,7 +92,7 @@ } catch (zypp::Exception & excpt) { - _last_error.setLastError(excpt.asUserString()); + _last_error.setLastError(ExceptionAsString(excpt)); ycperror("TargetInit has failed: %s", excpt.msg().c_str() ); return YCPError(excpt.msg().c_str(), YCPBoolean(false)); } @@ -117,7 +117,7 @@ } catch (zypp::Exception & excpt) { - _last_error.setLastError(excpt.asUserString()); + _last_error.setLastError(ExceptionAsString(excpt)); ycperror("TargetLoad has failed: %s", excpt.msg().c_str() ); return YCPError(excpt.msg().c_str(), YCPBoolean(false)); } @@ -152,7 +152,7 @@ } catch (zypp::Exception & excpt) { - _last_error.setLastError(excpt.asUserString()); + _last_error.setLastError(ExceptionAsString(excpt)); ycperror("TargetDisableSources has failed: %s", excpt.msg().c_str() ); return YCPBoolean(false); } @@ -176,7 +176,7 @@ } catch (zypp::Exception & excpt) { - _last_error.setLastError(excpt.asUserString()); + _last_error.setLastError(ExceptionAsString(excpt)); ycperror("TargetFinish has failed: %s", excpt.msg().c_str() ); return YCPBoolean(false); } @@ -206,7 +206,7 @@ } catch (zypp::Exception & excpt) { - _last_error.setLastError(excpt.asUserString()); + _last_error.setLastError(ExceptionAsString(excpt)); ycperror("TargetInstall has failed: %s", excpt.asString().c_str()); return YCPBoolean(false); } @@ -235,7 +235,7 @@ } catch (zypp::Exception & excpt) { - _last_error.setLastError(excpt.asUserString()); + _last_error.setLastError(ExceptionAsString(excpt)); ycperror("TargetRemove has failed: %s", excpt.asString().c_str()); return YCPBoolean(false); } @@ -260,7 +260,7 @@ } catch (zypp::Exception & excpt) { - _last_error.setLastError(excpt.asUserString()); + _last_error.setLastError(ExceptionAsString(excpt)); ycperror("TargetLogfile has failed: %s", excpt.asString().c_str()); return YCPBoolean(false); } @@ -463,7 +463,7 @@ } catch (zypp::Exception & excpt) { - _last_error.setLastError(excpt.asUserString()); + _last_error.setLastError(ExceptionAsString(excpt)); ycperror("TargetRebuildDB has failed: %s", excpt.msg().c_str() ); return YCPBoolean(false); } -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
lslezak@svn.opensuse.org