blob: a89cd4c0cbe1be61bc3e202dd5b9bd7cfceb08c0 [file] [log] [blame]
// Copyright 2017 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "peridot/bin/ledger/testing/quit_on_error.h"
#include <lib/fit/function.h>
namespace ledger {
bool QuitOnError(fit::closure quit_callback, Status status,
fxl::StringView description) {
if (status != Status::OK) {
FXL_LOG(ERROR) << description << " failed with status "
<< fidl::ToUnderlying(status) << ".";
quit_callback();
return true;
}
return false;
}
fit::function<void(Status)> QuitOnErrorCallback(fit::closure quit_callback,
std::string description) {
return [quit_callback = std::move(quit_callback),
description = std::move(description)](Status status) mutable {
QuitOnError(quit_callback.share(), status, description);
};
}
} // namespace ledger