Commit 3d5d6583 authored by Paweł Wegner's avatar Paweł Wegner

Capture exception by const reference.

parent a5bba40d
......@@ -514,7 +514,7 @@ std::pair<std::string, std::string> AmazonS3::extract(const std::string& str) {
auto json =
util::json::from_stream(std::stringstream(util::from_base64(str)));
return {json["b"].asString(), json["p"].asString()};
} catch (Json::Exception) {
} catch (const Json::Exception&) {
return {};
}
}
......@@ -528,7 +528,7 @@ bool AmazonS3::unpackCredentials(const std::string& code) {
secret_ = json["password"].asString();
region_ = json["region"].asString();
return true;
} catch (Json::Exception) {
} catch (const Json::Exception&) {
return false;
}
}
......
......@@ -227,7 +227,7 @@ bool ICloudProvider::deserializeSession(const std::string& serialized_data,
token = token_tmp;
hints = hints_tmp;
return true;
} catch (const std::exception&) {
} catch (const Json::Exception&) {
return false;
}
}
......@@ -368,7 +368,7 @@ std::pair<std::string, std::string> CloudProvider::credentialsFromString(
std::string username = json["username"].asString();
std::string password = json["password"].asString();
return {username, password};
} catch (Json::Exception) {
} catch (const Json::Exception&) {
return {};
}
}
......
......@@ -79,7 +79,7 @@ void upload(Request<EitherError<IItem>>::Pointer r,
path, sent + *length, callback);
else
r->done(Dropbox::toItem(json));
} catch (std::exception) {
} catch (const Json::Exception&) {
r->done(Error{IHttpRequest::Failure, e.right()->output().str()});
}
},
......
......@@ -148,7 +148,7 @@ AuthorizeRequest::Pointer HubiC::authorizeAsync() {
if (e.left()) return complete(e.left());
complete(nullptr);
});
} catch (std::exception) {
} catch (const Json::Exception &) {
complete(Error{IHttpRequest::Failure, e.right()->output().str()});
}
});
......
......@@ -62,7 +62,7 @@ void upload(Request<EitherError<IItem>>::Pointer r,
try {
auto json = util::json::from_stream(e.right()->output());
upload(r, upload_url, sent + *length, callback, json);
} catch (std::exception) {
} catch (const Json::Exception&) {
r->done(Error{IHttpRequest::Failure, e.right()->output().str()});
}
},
......@@ -101,7 +101,7 @@ ICloudProvider::UploadFileRequest::Pointer OneDrive::uploadFileAsync(
util::json::from_stream(e.right()->output());
upload(r, response["uploadUrl"].asString(), 0, callback,
response);
} catch (std::exception) {
} catch (const Json::Exception&) {
r->done(Error{IHttpRequest::Failure,
e.right()->output().str()});
}
......
......@@ -262,7 +262,7 @@ bool WebDav::unpackCredentials(const std::string& code) {
password_ = json["password"].asString();
webdav_url_ = json["webdav_url"].asString();
return true;
} catch (std::exception) {
} catch (const Json::Exception&) {
return false;
}
}
......
......@@ -100,7 +100,7 @@ ICloudProvider::UploadFileRequest::Pointer YandexDisk::uploadFileAsync(
if (e.left()) f(e.left());
try {
f(util::json::from_stream(e.right()->output())["href"].asString());
} catch (Json::Exception) {
} catch (const Json::Exception&) {
f(Error{IHttpRequest::Failure, e.right()->output().str()});
}
});
......
......@@ -57,7 +57,7 @@ YouTubeItem from_string(const std::string& id) {
util::json::from_stream(std::stringstream(util::from_base64(id)));
return {json["audio"].asBool(), json["playlist"].asBool(),
json["id"].asString()};
} catch (Json::Exception) {
} catch (const Json::Exception&) {
return {};
}
}
......@@ -161,7 +161,7 @@ EitherError<std::string> descramble(const std::string& scrambled,
auto function = find_descrambler_code(descrambler, stream);
return transform(scrambled, function,
transformations(find_helper(function, stream)));
} catch (const std::exception& e) {
} catch (const std::logic_error& e) {
return Error{IHttpRequest::Failure, e.what()};
}
}
......@@ -214,7 +214,7 @@ ICloudProvider::GetItemDataRequest::Pointer YouTube::getItemDataAsync(
try {
r->done(getItemDataResponse(e.right()->output(),
id_data.audio));
} catch (std::exception) {
} catch (const Json::Exception&) {
r->done(Error{IHttpRequest::Failure,
e.right()->output().str()});
}
......
......@@ -130,7 +130,7 @@ void AuthorizeRequest::oauth2Authorization(AuthorizeCompleted complete) {
auth->set_access_token(auth->refreshTokenResponse(r->output()));
lock.unlock();
return complete(nullptr);
} catch (std::exception) {
} catch (const std::exception&) {
return complete(Error{IHttpRequest::Failure, r->output().str()});
}
} else if ((!IHttpRequest::isClientError(e.left()->code_) &&
......@@ -156,7 +156,7 @@ void AuthorizeRequest::oauth2Authorization(AuthorizeCompleted complete) {
e.right()->output()));
lock.unlock();
complete(nullptr);
} catch (std::exception) {
} catch (const std::exception&) {
complete(
Error{IHttpRequest::Failure, e.right()->output().str()});
}
......
......@@ -46,7 +46,7 @@ CreateDirectoryRequest::CreateDirectoryRequest(std::shared_ptr<CloudProvider> p,
try {
request->done(provider()->createDirectoryResponse(
*parent, name, e.right()->output()));
} catch (std::exception) {
} catch (const std::exception&) {
request->done(
Error{IHttpRequest::Failure, e.right()->output().str()});
}
......
......@@ -54,7 +54,7 @@ ExchangeCodeRequest::ExchangeCodeRequest(std::shared_ptr<CloudProvider> p,
lock.unlock();
Token token{auth_token->refresh_token_, auth_token->token_};
r->done(token);
} catch (std::exception) {
} catch (const std::exception&) {
r->done(
Error{IHttpRequest::Failure, e.right()->output().str()});
}
......
......@@ -40,7 +40,7 @@ GetItemDataRequest::GetItemDataRequest(std::shared_ptr<CloudProvider> p,
try {
request->done(
provider()->getItemDataResponse(r.right()->output()));
} catch (std::exception) {
} catch (const std::exception&) {
request->done(
Error{IHttpRequest::Failure, r.right()->output().str()});
}
......
......@@ -57,7 +57,7 @@ GetItemUrlRequest::GetItemUrlRequest(std::shared_ptr<CloudProvider> p,
static_cast<Item*>(item.get())->set_url(url);
r->done(url);
}
} catch (std::exception) {
} catch (const std::exception&) {
r->done(
Error{IHttpRequest::Failure, e.right()->output().str()});
}
......
......@@ -51,7 +51,7 @@ ListDirectoryPageRequest::ListDirectoryPageRequest(
auto lst = r->provider()->listDirectoryResponse(
*directory, e.right()->output(), next_token);
r->done(PageData{lst, next_token});
} catch (std::exception) {
} catch (const std::exception&) {
r->done(
Error{IHttpRequest::Failure, e.right()->output().str()});
}
......
......@@ -77,7 +77,7 @@ void ListDirectoryRequest::work(IItem::Pointer directory,
else {
request->done(result_);
}
} catch (std::exception) {
} catch (const std::exception&) {
request->done(
Error{IHttpRequest::Failure, e.right()->output().str()});
}
......
......@@ -44,7 +44,7 @@ MoveItemRequest::MoveItemRequest(std::shared_ptr<CloudProvider> p,
try {
request->done(p->moveItemResponse(*source, *destination,
e.right()->output()));
} catch (std::exception) {
} catch (const std::exception&) {
request->done(
Error{IHttpRequest::Failure, e.right()->output().str()});
}
......
......@@ -41,7 +41,7 @@ RenameItemRequest::RenameItemRequest(std::shared_ptr<CloudProvider> p,
try {
request->done(
p->renameItemResponse(*item, name, e.right()->output()));
} catch (std::exception) {
} catch (const std::exception&) {
request->done(
Error{IHttpRequest::Failure, e.right()->output().str()});
}
......
......@@ -58,7 +58,7 @@ void UploadFileRequest::resolve(Request::Pointer request,
request->done(provider()->uploadFileResponse(*directory, filename,
stream_wrapper_.size_,
e.right()->output()));
} catch (std::exception) {
} catch (const std::exception&) {
request->done(
Error{IHttpRequest::Failure, e.right()->output().str()});
}
......
......@@ -101,7 +101,7 @@ FileId::FileId(const std::string& str) : folder_() {
auto json = json::from_stream(std::stringstream(util::from_base64(str)));
folder_ = json["t"].asBool();
id_ = json["id"].asString();
} catch (Json::Exception) {
} catch (const Json::Exception&) {
}
}
......
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