class BucketDeserializationException : public DatabaseException {
public:
- BucketDeserializationException(const PolicyBucketId &bucketId) : m_bucketId(bucketId) {}
+ BucketDeserializationException(const PolicyBucketId &bucket) : m_bucketId(bucket) {
+ m_message = "Could not deserialize bucket " + bucketId();
+ }
virtual ~BucketDeserializationException() {};
- const std::string message(void) const {
- if (m_message.empty()) {
- m_message = "Could not deserialize bucket " + m_bucketId;
- }
+ const std::string &message(void) const {
return m_message;
}
}
private:
- mutable std::string m_message;
+ std::string m_message;
PolicyBucketId m_bucketId;
};
class BucketNotExistsException : public Exception {
public:
BucketNotExistsException() = delete;
- BucketNotExistsException(const PolicyBucketId &bucketId) : m_bucketId(bucketId) {}
+ BucketNotExistsException(const PolicyBucketId &bucketId)
+ : m_bucketId(bucketId), m_message("BucketNotExistsException") {
+ }
virtual ~BucketNotExistsException() {};
- virtual const std::string message(void) const {
- return "BucketNotExistsException";
+ virtual const std::string &message(void) const {
+ return m_message;
}
const PolicyBucketId &bucketId(void) const {
private:
PolicyBucketId m_bucketId;
+ std::string m_message;
};
} /* namespace Cynara */
BucketRecordCorruptedException withLineNumber(const size_t &lineNumber) const {
BucketRecordCorruptedException copy(*this);
copy.m_lineNumber = lineNumber;
- copy.m_whatMsg.clear();
+ copy.m_message.clear();
return copy;
}
BucketRecordCorruptedException withFilename(const std::string &filename) const {
BucketRecordCorruptedException copy(*this);
copy.m_filename = filename;
- copy.m_whatMsg.clear();
+ copy.m_message.clear();
return copy;
}
- virtual const std::string message(void) const {
- if (m_whatMsg.empty()) {
- m_whatMsg = "Bucket record corrupted at"
+ virtual const std::string &message(void) const {
+ if (m_message.empty()) {
+ m_message = "Bucket record corrupted at"
+ formatedFilename()
+ formatedLineNumber()
+ ": <" + slicedLine() + ">";
}
- return m_whatMsg;
+ return m_message;
}
const std::string &filename(void) const {
size_t m_lineNumber;
std::string m_line;
std::string m_filename;
- mutable std::string m_whatMsg;
+ mutable std::string m_message;
};
} /* namespace Cynara */
class BucketSerializationException : public DatabaseException {
public:
- BucketSerializationException(const PolicyBucketId &bucketId) : m_bucketId(bucketId) {}
+ BucketSerializationException(const PolicyBucketId &bucket) : m_bucketId(bucket) {
+ m_message = "Could not serialize bucket " + bucketId();
+ }
virtual ~BucketSerializationException() {};
- const std::string message(void) const {
- if (m_message.empty()) {
- m_message = "Could not serialize bucket " + m_bucketId;
- }
+ const std::string &message(void) const {
return m_message;
}
}
private:
- mutable std::string m_message;
+ std::string m_message;
PolicyBucketId m_bucketId;
};
class CannotCreateFileException : public DatabaseException {
public:
- CannotCreateFileException(const std::string &filename) : m_filename(filename) {};
+ CannotCreateFileException(const std::string &file) : m_filename(file) {
+ m_message = "File " + filename() + " cannot be created";
+ };
virtual ~CannotCreateFileException() {};
- const std::string message(void) const {
- if (m_message.empty()) {
- m_message = "File " + filename() + " cannot be created";
- }
+ const std::string &message(void) const {
return m_message;
}
}
private:
- mutable std::string m_message;
+ std::string m_message;
std::string m_filename;
};
class ContextErrorException : public Exception {
public:
- ContextErrorException() = default;
+ ContextErrorException() : m_message("ContextErrorException") {}
virtual ~ContextErrorException() {};
- virtual const std::string message(void) const {
- return "ContextErrorException";
+ virtual const std::string &message(void) const {
+ return m_message;
}
+
+private:
+ std::string m_message;
};
} /* namespace Cynara */
class DefaultBucketDeletionException : public Exception {
public:
- DefaultBucketDeletionException() = default;
+ DefaultBucketDeletionException() : m_message("DefaultBucketDeletionException") {
+ }
virtual ~DefaultBucketDeletionException() {};
- virtual const std::string message(void) const {
- return "DefaultBucketDeletionException";
+ virtual const std::string &message(void) const {
+ return m_message;
}
+
+private:
+ std::string m_message;
};
} /* namespace Cynara */
class DefaultBucketSetNoneException : public Exception {
public:
- DefaultBucketSetNoneException() = default;
+ DefaultBucketSetNoneException() : m_message("DefaultBucketSetNoneException") {
+ }
virtual ~DefaultBucketSetNoneException() {};
- virtual const std::string message(void) const {
- return "DefaultBucketSetNoneException";
+ virtual const std::string &message(void) const {
+ return m_message;
}
+
+private:
+ std::string m_message;
};
} /* namespace Cynara */
public:
DescriptorNotExistsException() = delete;
DescriptorNotExistsException(int desc) {
- std::ostringstream stream;
- stream << "trying access not existing descriptor [" << desc << "]";
- m_whatMsg = stream.str();
+ m_message = "trying access not existing descriptor [" + std::to_string(desc) + "]";
}
virtual ~DescriptorNotExistsException() {};
- virtual const std::string message(void) const {
- return m_whatMsg;
+ virtual const std::string &message(void) const {
+ return m_message;
}
private:
- std::string m_whatMsg;
+ std::string m_message;
};
} // namespace Cynara
return m_whatMessage.c_str();
}
- virtual const std::string message(void) const = 0;
+ virtual const std::string &message(void) const = 0;
private:
std::string m_backtrace;
class FileNotFoundException : public DatabaseException {
public:
- FileNotFoundException(const std::string &filename) : m_filename(filename) {};
- virtual ~FileNotFoundException() {};
+ FileNotFoundException(const std::string &file) : m_filename(file) {
+ m_message = "File " + filename() + " not found or corrupted badly";
+ }
+ virtual ~FileNotFoundException() {}
- const std::string message(void) const {
- if (m_message.empty()) {
- m_message = "File " + filename() + " not found or corrupted badly";
- }
+ const std::string &message(void) const {
return m_message;
}
}
private:
- mutable std::string m_message;
+ std::string m_message;
std::string m_filename;
};
class InitException : public Exception {
public:
- InitException() = default;
+ InitException() : m_message("InitException") {}
virtual ~InitException() {};
- virtual const std::string message(void) const {
- return "InitException";
+ virtual const std::string &message(void) const {
+ return m_message;
}
+
+private:
+ std::string m_message;
};
} /* namespace Cynara */
class InvalidBucketIdException : public Exception {
public:
- InvalidBucketIdException(const std::string &bucketId) : m_bucketId(bucketId) {};
+ InvalidBucketIdException(const std::string &bucket) : m_bucketId(bucket) {
+ m_message = "Bucket ID " + bucketId() + " contains forbidden characters";
+ };
virtual ~InvalidBucketIdException() {};
- const std::string message(void) const {
- if (m_message.empty()) {
- m_message = "Bucket ID " + bucketId() + " contains forbidden characters";
- }
+ const std::string &message(void) const {
return m_message;
}
}
private:
- mutable std::string m_message;
+ std::string m_message;
std::string m_bucketId;
};
m_exceptionType(exceptionType) {
switch(m_exceptionType) {
case InvalidSignature:
- m_whatMessage = "No valid signature found";
+ m_message = "No valid signature found";
break;
case WrongOpCode:
- m_whatMessage = "Wrong request code";
+ m_message = "Wrong request code";
break;
case Other:
- m_whatMessage = "Unknown problem";
+ m_message = "Unknown problem";
break;
}
}
virtual ~InvalidProtocolException() {};
- virtual const std::string message(void) const {
- return m_whatMessage;
+ virtual const std::string &message(void) const {
+ return m_message;
}
ExceptionType exceptionType(void) const {
}
private:
- std::string m_whatMessage;
+ std::string m_message;
ExceptionType m_exceptionType;
};
public:
NoMemoryException() = delete;
NoMemoryException(const std::string &errorMsg) {
- m_whatMessage = "NoMemoryException with message <" + errorMsg + ">";
+ m_message = "NoMemoryException with message <" + errorMsg + ">";
}
virtual ~NoMemoryException() {};
- virtual const std::string message(void) const {
- return m_whatMessage;
+ virtual const std::string &message(void) const {
+ return m_message;
}
private:
- std::string m_whatMessage;
+ std::string m_message;
};
} // namespace Cynara
class NotImplementedException : public Exception {
public:
- NotImplementedException() = default;
+ NotImplementedException() :m_message("NotImplementedException") {}
virtual ~NotImplementedException() {};
- virtual const std::string message(void) const {
- return "NotImplementedException";
+ virtual const std::string &message(void) const {
+ return m_message;
}
+
+private:
+ std::string m_message;
};
} /* namespace Cynara */
public:
NullPointerException() = delete;
NullPointerException(const char *varName) {
- m_whatMsg = std::string("unexpected null value in variable <")
- + std::string(varName)
- + std::string(">");
+ m_message = "unexpected null value in variable <" + std::string(varName) + ">";
}
virtual ~NullPointerException() {};
- virtual const std::string message(void) const {
- return m_whatMsg;
+ virtual const std::string &message(void) const {
+ return m_message;
}
private:
- std::string m_whatMsg;
+ std::string m_message;
};
} // namespace Cynara
public:
OutOfDataException() = delete;
OutOfDataException(size_t dataRange, size_t accessTry) {
- std::ostringstream stream;
- stream << "trying access [" << accessTry << "]";
- stream << " which exceeds data range [" << dataRange << "]";
- m_whatMsg = stream.str();
+ m_message = "trying access [" + std::to_string(accessTry) + "]"
+ + " which exceeds data range [" + std::to_string(dataRange) + "]";
}
virtual ~OutOfDataException() {};
- virtual const std::string message(void) const {
- return m_whatMsg;
+ virtual const std::string &message(void) const {
+ return m_message;
}
private:
- std::string m_whatMsg;
+ std::string m_message;
};
} // namespace Cynara
"privilege <" + key.privilege().toString() + ">";
}
- const std::string message(void) const {
+ const std::string &message(void) const {
return m_message;
}
public:
PluginNotFoundException() = delete;
PluginNotFoundException(const PolicyResult &result) {
- std::ostringstream stream;
- stream << "No proper plugin found to interprete PolicyResult {type = ["
- << result.policyType() << "], metadata = <"
- << result.metadata().substr(0, 20) << ">}";
- m_whatMessage = stream.str();
+ m_message = "No proper plugin found to interprete PolicyResult {type = ["
+ + std::to_string(result.policyType()) + "], metadata = <"
+ + result.metadata().substr(0, 20) + ">}";
}
virtual ~PluginNotFoundException() {};
- virtual const std::string message(void) const {
- return m_whatMessage;
+ virtual const std::string &message(void) const {
+ return m_message;
}
private:
- std::string m_whatMessage;
+ std::string m_message;
};
} // namespace Cynara
public:
UnexpectedErrorException() = delete;
UnexpectedErrorException(int errorCode, const char *errorMsg) {
- std::ostringstream stream;
- stream << "UnexpectedErrorException with errorCode =[" << errorCode << "] and message <";
- stream << errorMsg << ">";
- m_whatMessage = stream.str();
+ m_message = "UnexpectedErrorException with errorCode =[" + std::to_string(errorCode)
+ + "] and message <" + errorMsg + ">";
}
UnexpectedErrorException(const char *errorMsg) {
- std::ostringstream stream;
- stream << "UnexpectedErrorException with message <";
- stream << errorMsg << ">";
- m_whatMessage = stream.str();
+ m_message = "UnexpectedErrorException with message <" + std::string(errorMsg) + ">";
}
virtual ~UnexpectedErrorException() {};
- virtual const std::string message(void) const {
- return m_whatMessage;
+ virtual const std::string &message(void) const {
+ return m_message;
}
private:
- std::string m_whatMessage;
+ std::string m_message;
};
} // namespace Cynara