message: Add detail on state mismatch
diff: @@ -42,6 +42,47 @@ extern "C"
  #include <evercrypt/EverCrypt_AutoConfig2.h>
  }
  +namespace ccf
  +{
  + enum class State
  + {
  + uninitialized,
  + initialized,
  + pending,
  + partOfPublicNetwork,
  + partOfNetwork,
  + readingPublicLedger,
  + readingPrivateLedger
  + };
  +}
  +
  +// Used by fmtlib to render ccf::State
  +namespace std
  +{
  + std::ostream& operator<<(std::ostream& os, ccf::State s)
  + {
  + switch (s)
  + {
  + case ccf::State::uninitialized:
  + return os << "uninitialized";
  + case ccf::State::initialized:
  + return os << "initialized";
  + case ccf::State::pending:
  + return os << "pending";
  + case ccf::State::partOfPublicNetwork:
  + return os << "partOfPublicNetwork";
  + case ccf::State::partOfNetwork:
  + return os << "partOfNetwork";
  + case ccf::State::readingPublicLedger:
  + return os << "readingPublicLedger";
  + case ccf::State::readingPrivateLedger:
  + return os << "readingPrivateLedger";
  + default:
  + return os << "unknown value";
  + }
  + }
  +}
  +
  namespace ccf
  {
  using RaftConsensusType =
  @@ -61,8 +102,12 @@ namespace ccf
  StateMachine(T s) : s(s) {}
  void expect(T s) const
  {
  - if (s != this->s.load())
  - throw std::logic_error("Unexpected state");
  + auto state = this->s.load();
  + if (s != state)
  + {
  + throw std::logic_error(
  + fmt::format("State is {}, but expected {}", state, s));
  + }
  }
  bool check(T s) const
  @@ -101,17 +146,6 @@ namespace ccf
  return {{}, false};
  }
  - enum class State
  - {
  - uninitialized,
  - initialized,
  - pending,
  - partOfPublicNetwork,
  - partOfNetwork,
  - readingPublicLedger,
  - readingPrivateLedger
  - };
  -
  //
  // this node's core state
  //
  