From: Andrii Grynenko Date: Wed, 31 Aug 2016 21:12:57 +0000 (-0700) Subject: Properly report observable returning nullptr X-Git-Tag: v2016.09.05.00~4 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=2f9872199a404b4290d81619520f04295864b16e;p=folly.git Properly report observable returning nullptr Summary: Make sure exception is propagated to caller (especially when Observer is just created). Reviewed By: yfeldblum Differential Revision: D3798991 fbshipit-source-id: cee8452cfd40dcfbaf0e2ae2c2ee628af0362c6e --- diff --git a/folly/experimental/observer/Observable-inl.h b/folly/experimental/observer/Observable-inl.h index 75061ac2..9bd3c83d 100644 --- a/folly/experimental/observer/Observable-inl.h +++ b/folly/experimental/observer/Observable-inl.h @@ -42,7 +42,9 @@ class ObserverCreator::Context { void update() { { auto newValue = Traits::get(observable_); - DCHECK(newValue); + if (!newValue) { + throw std::logic_error("Observable returned nullptr."); + } value_.swap(newValue); }