Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
20 changed files
with
1,577 additions
and
616 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include <../os/package/CommitTransactionResult.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
/* | ||
* Copyright 2014, Haiku, Inc. All Rights Reserved. | ||
* Distributed under the terms of the MIT License. | ||
*/ | ||
#ifndef _PACKAGE__COMMIT_TRANSACTION_RESULT_H_ | ||
#define _PACKAGE__COMMIT_TRANSACTION_RESULT_H_ | ||
|
||
|
||
#include <ObjectList.h> | ||
#include <String.h> | ||
|
||
|
||
class BMessage; | ||
|
||
|
||
namespace BPackageKit { | ||
|
||
|
||
enum BTransactionError { | ||
B_TRANSACTION_OK = 0, | ||
B_TRANSACTION_NO_MEMORY, | ||
B_TRANSACTION_INTERNAL_ERROR, | ||
B_TRANSACTION_INSTALLATION_LOCATION_BUSY, | ||
B_TRANSACTION_CHANGE_COUNT_MISMATCH, | ||
B_TRANSACTION_BAD_REQUEST, | ||
B_TRANSACTION_NO_SUCH_PACKAGE, | ||
B_TRANSACTION_PACKAGE_ALREADY_EXISTS, | ||
B_TRANSACTION_FAILED_TO_GET_ENTRY_PATH, | ||
B_TRANSACTION_FAILED_TO_OPEN_DIRECTORY, | ||
B_TRANSACTION_FAILED_TO_CREATE_DIRECTORY, | ||
B_TRANSACTION_FAILED_TO_REMOVE_DIRECTORY, | ||
B_TRANSACTION_FAILED_TO_MOVE_DIRECTORY, | ||
B_TRANSACTION_FAILED_TO_WRITE_ACTIVATION_FILE, | ||
B_TRANSACTION_FAILED_TO_READ_PACKAGE_FILE, | ||
B_TRANSACTION_FAILED_TO_EXTRACT_PACKAGE_FILE, | ||
B_TRANSACTION_FAILED_TO_OPEN_FILE, | ||
B_TRANSACTION_FAILED_TO_MOVE_FILE, | ||
B_TRANSACTION_FAILED_TO_COPY_FILE, | ||
B_TRANSACTION_FAILED_TO_WRITE_FILE_ATTRIBUTE, | ||
B_TRANSACTION_FAILED_TO_ACCESS_ENTRY, | ||
B_TRANSACTION_FAILED_TO_ADD_GROUP, | ||
B_TRANSACTION_FAILED_TO_ADD_USER, | ||
B_TRANSACTION_FAILED_TO_ADD_USER_TO_GROUP, | ||
B_TRANSACTION_FAILED_TO_CHANGE_PACKAGE_ACTIVATION, | ||
}; | ||
|
||
|
||
class BTransactionIssue { | ||
public: | ||
enum BType { | ||
B_WRITABLE_FILE_TYPE_MISMATCH, | ||
B_WRITABLE_FILE_NO_PACKAGE_ATTRIBUTE, | ||
B_WRITABLE_FILE_OLD_ORIGINAL_FILE_MISSING, | ||
B_WRITABLE_FILE_OLD_ORIGINAL_FILE_TYPE_MISMATCH, | ||
B_WRITABLE_FILE_COMPARISON_FAILED, | ||
B_WRITABLE_FILE_NOT_EQUAL, | ||
B_WRITABLE_SYMLINK_COMPARISON_FAILED, | ||
B_WRITABLE_SYMLINK_NOT_EQUAL, | ||
B_POST_INSTALL_SCRIPT_NOT_FOUND, | ||
B_STARTING_POST_INSTALL_SCRIPT_FAILED, | ||
B_POST_INSTALL_SCRIPT_FAILED, | ||
}; | ||
|
||
public: | ||
BTransactionIssue(); | ||
BTransactionIssue(BType type, | ||
const BString& packageName, | ||
const BString& path1, const BString& path2, | ||
status_t systemError, int exitCode); | ||
BTransactionIssue( | ||
const BTransactionIssue& other); | ||
~BTransactionIssue(); | ||
|
||
BType Type() const; | ||
const BString& PackageName() const; | ||
const BString& Path1() const; | ||
const BString& Path2() const; | ||
status_t SystemError() const; | ||
int ExitCode() const; | ||
|
||
BString ToString() const; | ||
|
||
status_t AddToMessage(BMessage& message) const; | ||
status_t ExtractFromMessage(const BMessage& message); | ||
|
||
BTransactionIssue& operator=(const BTransactionIssue& other); | ||
|
||
private: | ||
BType fType; | ||
BString fPackageName; | ||
BString fPath1; | ||
BString fPath2; | ||
status_t fSystemError; | ||
int fExitCode; | ||
}; | ||
|
||
|
||
class BCommitTransactionResult { | ||
public: | ||
BCommitTransactionResult(); | ||
BCommitTransactionResult( | ||
BTransactionError error); | ||
BCommitTransactionResult( | ||
const BCommitTransactionResult& other); | ||
~BCommitTransactionResult(); | ||
|
||
void Unset(); | ||
|
||
int32 CountIssues() const; | ||
const BTransactionIssue* IssueAt(int32 index) const; | ||
bool AddIssue(const BTransactionIssue& issue); | ||
|
||
BTransactionError Error() const; | ||
void SetError(BTransactionError error); | ||
|
||
status_t SystemError() const; | ||
void SetSystemError(status_t error); | ||
|
||
const BString& ErrorPackage() const; | ||
// may be empty, even on error | ||
void SetErrorPackage(const BString& packageName); | ||
|
||
BString FullErrorMessage() const; | ||
|
||
const BString& Path1() const; | ||
void SetPath1(const BString& path); | ||
|
||
const BString& Path2() const; | ||
void SetPath2(const BString& path); | ||
|
||
const BString& Path3() const; | ||
void SetPath3(const BString& path); | ||
|
||
const BString& String1() const; | ||
void SetString1(const BString& string); | ||
|
||
const BString& String2() const; | ||
void SetString2(const BString& string); | ||
|
||
const BString& OldStateDirectory() const; | ||
void SetOldStateDirectory(const BString& directory); | ||
|
||
status_t AddToMessage(BMessage& message) const; | ||
status_t ExtractFromMessage(const BMessage& message); | ||
|
||
BCommitTransactionResult& operator=( | ||
const BCommitTransactionResult& other); | ||
|
||
private: | ||
typedef BObjectList<BTransactionIssue> IssueList; | ||
|
||
private: | ||
BTransactionError fError; | ||
status_t fSystemError; | ||
BString fErrorPackage; | ||
BString fPath1; | ||
BString fPath2; | ||
BString fString1; | ||
BString fString2; | ||
BString fOldStateDirectory; | ||
IssueList fIssues; | ||
}; | ||
|
||
|
||
} // namespace BPackageKit | ||
|
||
|
||
#endif // _PACKAGE__COMMIT_TRANSACTION_RESULT_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.