1/* 2 * Copyright 2013-2014, Ingo Weinhold, ingo_weinhold@gmx.de. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 7#include <package/manager/Exceptions.h> 8 9#include <stdarg.h> 10 11 12namespace BPackageKit { 13 14namespace BManager { 15 16namespace BPrivate { 17 18 19// #pragma mark - BException 20 21 22BException::BException() 23 : 24 fMessage() 25{ 26} 27 28 29BException::BException(const BString& message) 30 : 31 fMessage(message) 32{ 33} 34 35 36// #pragma mark - BFatalErrorException 37 38 39BFatalErrorException::BFatalErrorException() 40 : 41 BException(), 42 fDetails(), 43 fError(B_OK), 44 fCommitTransactionResult(), 45 fCommitTransactionFailed(false) 46{ 47} 48 49 50BFatalErrorException::BFatalErrorException(const char* format, ...) 51 : 52 BException(), 53 fDetails(), 54 fError(B_OK), 55 fCommitTransactionResult(), 56 fCommitTransactionFailed(false) 57{ 58 va_list args; 59 va_start(args, format); 60 fMessage.SetToFormatVarArgs(format, args); 61 va_end(args); 62} 63 64 65BFatalErrorException::BFatalErrorException(status_t error, const char* format, 66 ...) 67 : 68 BException(), 69 fDetails(), 70 fError(error), 71 fCommitTransactionResult(), 72 fCommitTransactionFailed(false) 73{ 74 va_list args; 75 va_start(args, format); 76 fMessage.SetToFormatVarArgs(format, args); 77 va_end(args); 78} 79 80 81BFatalErrorException::BFatalErrorException( 82 const BCommitTransactionResult& result) 83 : 84 BException(), 85 fDetails(), 86 fError(B_OK), 87 fCommitTransactionResult(result), 88 fCommitTransactionFailed(true) 89{ 90 fMessage.SetToFormat("failed to commit transaction: %s", 91 result.FullErrorMessage().String()); 92} 93 94 95BFatalErrorException& 96BFatalErrorException::SetDetails(const BString& details) 97{ 98 fDetails = details; 99 return *this; 100} 101 102 103// #pragma mark - BAbortedByUserException 104 105 106BAbortedByUserException::BAbortedByUserException() 107 : 108 BException() 109{ 110} 111 112 113// #pragma mark - BNothingToDoException 114 115 116BNothingToDoException::BNothingToDoException() 117 : 118 BException() 119{ 120} 121 122 123} // namespace BPrivate 124 125} // namespace BManager 126 127} // namespace BPackageKit 128