Fix

parent 23e5ad22
...@@ -29,7 +29,8 @@ ...@@ -29,7 +29,8 @@
#include "leveldb/db.h" #include "leveldb/db.h"
#include "sgxwallet_common.h"
#include "RPCException.h"
#include "LevelDB.h" #include "LevelDB.h"
using namespace leveldb; using namespace leveldb;
...@@ -48,7 +49,7 @@ std::shared_ptr<std::string> LevelDB::readString(const std::string &_key) { ...@@ -48,7 +49,7 @@ std::shared_ptr<std::string> LevelDB::readString(const std::string &_key) {
auto result = std::make_shared<std::string>(); auto result = std::make_shared<std::string>();
if (db == nullptr) { if (db == nullptr) {
throw std::runtime_error("Null db"); throw RPCException(NULL_DATABASE, "Null db");
} }
auto status = db->Get(readOptions, _key, &*result); auto status = db->Get(readOptions, _key, &*result);
...@@ -94,9 +95,9 @@ void LevelDB::writeByteArray(std::string &_key, const char *value, ...@@ -94,9 +95,9 @@ void LevelDB::writeByteArray(std::string &_key, const char *value,
void LevelDB::throwExceptionOnError(Status _status) { void LevelDB::throwExceptionOnError(Status _status) {
if (_status.IsNotFound()) if (_status.IsNotFound())
return; return;
git
if (!_status.ok()) { if (!_status.ok()) {
throw std::runtime_error("Could not write to database:" + _status.ToString()); throw RPCException(COULD_NOT_ACCESS_DATABASE, ("Could not access database database:" + _status.ToString()).c_str());
} }
} }
......
...@@ -36,6 +36,8 @@ ...@@ -36,6 +36,8 @@
#define SEAL_KEY_FAILED -7 #define SEAL_KEY_FAILED -7
#define KEY_SHARE_DOES_NOT_EXIST -7 #define KEY_SHARE_DOES_NOT_EXIST -7
#define KEY_SHARE_ALREADY_EXISTS -8 #define KEY_SHARE_ALREADY_EXISTS -8
#define COULD_NOT_ACCESS_DATABASE -9
#define NULL_DATABASE -10
#define WALLETDB_NAME "sgxwallet.db" #define WALLETDB_NAME "sgxwallet.db"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment