package daemon: Rework error and issue propagation to client

* BDaemonClient: Move inner class BCommitTransactionResult to top level
  and make it public.
* BCommitTransactionResult:
  - Add a whole bunch of specific error code enum values. Such an error
    code is now the primary error, as opposed to before where we would
    mix status_t and enum value errors. There's a systemError property
    of type status_t which may provide additional information, though
    (depending on the primary error type).
  - Remove the errorMessage property. Due to mapping all errors to the
    specific error codes this is no longer necessary. Mixing such a
    message with another error description is also not very helpful when
    it comes to localization (still not supported, though).
  - Add several properties (paths, strings, error codes) that serve as
    arguments to the primary error and are used by FullErrorMessage().
  - Add issues property, a list of instances of new class
    BTransactionIssue. Those describe non-critical issues (e.g. failed
    update of a settings file) that occurred in the process of
    committing the transaction. Those issues should be presented to the
    user by the package management program.
* Exception: Adjust to transport the BCommitTransactionResult
  properties.
* CommitTransactionHandler, FsTransactions, Root, Volume: Adjust to
  BCommitTransactionResult/Exception changes.
* CommitTransactionHandler: Now requires a BCommitTransactionResult to
  which it adds the issues it encounters. The reply BMessage is no
  longer needed, though.
* Volume: Refactor common code from the three methods that use
  CommitTransactionHandler into new method _CommitTransaction.
This commit is contained in:
Ingo Weinhold
2014-06-15 17:21:01 +02:00
parent 6077cad882
commit 0de3219e33
20 changed files with 1573 additions and 612 deletions
+1 -38
View File
@@ -22,6 +22,7 @@ class BDirectory;
namespace BPackageKit {
class BCommitTransactionResult;
class BInstallationLocationInfo;
class BPackageInfoSet;
@@ -33,9 +34,6 @@ class BActivationTransaction;
class BDaemonClient {
public:
class BCommitTransactionResult;
public:
BDaemonClient();
~BDaemonClient();
@@ -65,41 +63,6 @@ private:
};
class BDaemonClient::BCommitTransactionResult {
public:
BCommitTransactionResult();
BCommitTransactionResult(int32 error,
const BString& errorMessage,
const BString& errorPackage,
const BString& oldStateDirectory);
~BCommitTransactionResult();
void SetTo(int32 error, const BString& errorMessage,
const BString& errorPackage,
const BString& oldStateDirectory);
status_t Error() const;
BDaemonError DaemonError() const;
// may be B_DAEMON_OK, even if Error() is
// != B_OK, then Error() is as specific as
// is known
const BString& ErrorMessage() const;
// may be empty, even on error
const BString& ErrorPackage() const;
// may be empty, even on error
BString FullErrorMessage() const;
const BString& OldStateDirectory() const;
private:
int32 fError;
BString fErrorMessage;
BString fErrorPackage;
BString fOldStateDirectory;
};
} // namespace BPrivate
} // namespace BPackageKit
+30 -17
View File
@@ -16,16 +16,6 @@ namespace BPrivate {
#define B_PACKAGE_DAEMON_APP_SIGNATURE "application/x-vnd.haiku-package_daemon"
enum BDaemonError {
B_DAEMON_OK = 0,
B_DAEMON_INSTALLATION_LOCATION_BUSY,
B_DAEMON_CHANGE_COUNT_MISMATCH,
B_DAEMON_BAD_REQUEST,
B_DAEMON_NO_SUCH_PACKAGE,
B_DAEMON_PACKAGE_ALREADY_EXISTS
};
// message codes for requests to and replies from the daemon
enum {
B_MESSAGE_GET_INSTALLATION_LOCATION_INFO = 'PKLI',
@@ -59,17 +49,40 @@ enum {
// transaction directory
B_MESSAGE_COMMIT_TRANSACTION_REPLY = 'PKTR'
// "error": int32
// regular error code or BDaemonError describing how committing
// the transaction went
// "error message": string
// [error case only] gives some additional information what went
// wrong; optional
// a BTransactionError describing how committing the transaction
// went
// "system error": int32
// a status_t for the operation that failed; B_ERROR, if n/a
// "error package": string
// [error case only] file name of the package causing the error,
// if any in particarly; optional
// "path1": string
// [error case only] first path specific to the error
// "path2": string
// [error case only] second path specific to the error
// "string1": string
// [error case only] first string specific to the error
// "string2": string
// [error case only] second string specific to the error
// "old state": string
// name of the directory (subdirectory of the administrative
// directory) containing the deactivated packages
// [success case only] name of the directory (subdirectory of the
// administrative directory) containing the deactivated packages
// "issues": message[]
// A list of non-critical issues that occurred while performing the
// package activation. On success the user should be notified about
// these. Each contains:
// "type": int32
// a BTransactionIssue::BType specifying the kind of issue
// "package": string
// file name of the package which the issue is related to
// "path1": string
// first path specific to the issue
// "path2": string
// second path specific to the issue
// "system error": int32
// a status_t for the operation that failed; B_OK, if n/a
// "exit code": int32
// a exit code of the program that failed; 0, if n/a
};
@@ -234,8 +234,7 @@ public:
virtual status_t PrepareTransaction(Transaction& transaction)
= 0;
virtual status_t CommitTransaction(Transaction& transaction,
BDaemonClient::BCommitTransactionResult&
_result) = 0;
BCommitTransactionResult& _result) = 0;
};
@@ -250,8 +249,7 @@ public:
virtual status_t PrepareTransaction(Transaction& transaction);
virtual status_t CommitTransaction(Transaction& transaction,
BDaemonClient::BCommitTransactionResult&
_result);
BCommitTransactionResult& _result);
private:
BDaemonClient fDaemonClient;