folly: improve Subprocess::enforce() error message
authorLucian Grijincu <lucian@fb.com>
Tue, 20 Aug 2013 22:50:39 +0000 (15:50 -0700)
committerSara Golemon <sgolemon@fb.com>
Wed, 28 Aug 2013 21:30:12 +0000 (14:30 -0700)
Summary: Previous implementation only printed the desired state, not the actual runtime state. Fix that.

Test Plan: n/a

Reviewed By: tudorb@fb.com

FB internal diff: D936279

folly/Subprocess.cpp

index fb4c19a95ee9bb1e998b426449cb2f1709112751..846076dd22c0e7ccefe91e07917d5e4e4cf0666d 100644 (file)
@@ -54,9 +54,11 @@ ProcessReturnCode::State ProcessReturnCode::state() const {
       "Invalid ProcessReturnCode: ", rawStatus_));
 }
 
-void ProcessReturnCode::enforce(State s) const {
-  if (state() != s) {
-    throw std::logic_error(to<std::string>("Invalid state ", s));
+void ProcessReturnCode::enforce(State expected) const {
+  State s = state();
+  if (s != expected) {
+    throw std::logic_error(to<std::string>("Invalid state ", s,
+                                           " expected ", expected));
   }
 }