Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: src/DefaultFileSystem.cpp

Issue 29731562: Issue 6477 - separate done and error callbacks in IFileSystem::Read (Closed) Base URL: https://github.com/adblockplus/libadblockplus.git@c0a6434596a83383e37678ef3b6ecef00ed6a261
Patch Set: Created March 23, 2018, 10:58 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/DefaultFileSystem.cpp
diff --git a/src/DefaultFileSystem.cpp b/src/DefaultFileSystem.cpp
index 35ef355b22e28583a8d74b0f62228b3e1abdf0a2..f94bd01a8a71c8825eda6dba29c462126789f936 100644
--- a/src/DefaultFileSystem.cpp
+++ b/src/DefaultFileSystem.cpp
@@ -201,15 +201,15 @@ DefaultFileSystem::DefaultFileSystem(const Scheduler& scheduler, std::unique_ptr
}
void DefaultFileSystem::Read(const std::string& fileName,
- const ReadCallback& callback) const
+ const ReadCallback& doneCallback,
+ const Callback& errorCallback) const
{
- scheduler([this, fileName, callback]
+ scheduler([this, fileName, doneCallback, errorCallback]
{
std::string error;
try
{
- auto data = syncImpl->Read(Resolve(fileName));
- callback(std::move(data), error);
+ doneCallback(syncImpl->Read(Resolve(fileName)));
return;
}
catch (std::exception& e)
@@ -220,7 +220,15 @@ void DefaultFileSystem::Read(const std::string& fileName,
{
error = "Unknown error while reading from " + fileName + " as " + Resolve(fileName);
}
- callback(IOBuffer(), error);
+
+ try
+ {
+ errorCallback(error);
+ }
+ catch (...)
+ {
+ // there is no way to catch an exception thrown from the error callback.
+ }
});
}
« no previous file with comments | « src/DefaultFileSystem.h ('k') | src/FileSystemJsObject.cpp » ('j') | src/FileSystemJsObject.cpp » ('J')

Powered by Google App Engine
This is Rietveld