Summary: If an exception is thrown from the plugin, FlipperClient.cpp will catch it and respond with an error response. If the object goes out of scope with no response being returned, then return a success response in the destructor. Reviewed By: passy Differential Revision: D14024259 fbshipit-source-id: 52e419dd23fc3882e8b92b593e8c1e1ea90e2b26
42 lines
970 B
C++
42 lines
970 B
C++
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the LICENSE
|
|
* file in the root directory of this source tree.
|
|
*/
|
|
#pragma once
|
|
|
|
#include <Flipper/FlipperResponder.h>
|
|
#include <folly/json.h>
|
|
#include <vector>
|
|
|
|
namespace facebook {
|
|
namespace flipper {
|
|
|
|
class FlipperResponderMock : public FlipperResponder {
|
|
public:
|
|
FlipperResponderMock(
|
|
std::vector<folly::dynamic>* successes = nullptr,
|
|
std::vector<folly::dynamic>* errors = nullptr)
|
|
: successes_(successes), errors_(errors) {}
|
|
|
|
void success(const folly::dynamic& response) override {
|
|
if (successes_) {
|
|
successes_->push_back(response);
|
|
}
|
|
}
|
|
|
|
void error(const folly::dynamic& response) override {
|
|
if (errors_) {
|
|
errors_->push_back(response);
|
|
}
|
|
}
|
|
|
|
private:
|
|
std::vector<folly::dynamic>* successes_;
|
|
std::vector<folly::dynamic>* errors_;
|
|
};
|
|
|
|
} // namespace flipper
|
|
} // namespace facebook
|