libweave: Remove error pointer from ToJson methods

Converting to Json should not ever fail.

BUG=brillo:1246
TEST='FEATURES=test emerge-gizmo buffet'

Change-Id: I90b76927ae5bf50c21e8278b9c0e6c411bd61b56
Reviewed-on: https://chromium-review.googlesource.com/289303
Reviewed-by: Vitaly Buka <vitalybuka@chromium.org>
Commit-Queue: Vitaly Buka <vitalybuka@chromium.org>
Tested-by: Vitaly Buka <vitalybuka@chromium.org>
diff --git a/buffet/manager.cc b/buffet/manager.cc
index 06de9f1..1ee1793 100644
--- a/buffet/manager.cc
+++ b/buffet/manager.cc
@@ -144,9 +144,8 @@
 }
 
 bool Manager::GetState(chromeos::ErrorPtr* error, std::string* state) {
-  auto json = device_->GetState()->GetStateValuesAsJson(error);
-  if (!json)
-    return false;
+  auto json = device_->GetState()->GetStateValuesAsJson();
+  CHECK(json);
   base::JSONWriter::WriteWithOptions(
       *json, base::JSONWriter::OPTIONS_PRETTY_PRINT, state);
   return true;
@@ -251,7 +250,7 @@
 }
 
 void Manager::OnStateChanged() {
-  auto state = device_->GetState()->GetStateValuesAsJson(nullptr);
+  auto state = device_->GetState()->GetStateValuesAsJson();
   CHECK(state);
   std::string json;
   base::JSONWriter::WriteWithOptions(
diff --git a/libweave/include/weave/state.h b/libweave/include/weave/state.h
index bf87a64..d34b408 100644
--- a/libweave/include/weave/state.h
+++ b/libweave/include/weave/state.h
@@ -22,8 +22,8 @@
 
   // Returns aggregated state properties across all registered packages as
   // a JSON object that can be used to send the device state to the GCD server.
-  virtual std::unique_ptr<base::DictionaryValue> GetStateValuesAsJson(
-      chromeos::ErrorPtr* error) const = 0;
+  virtual std::unique_ptr<base::DictionaryValue> GetStateValuesAsJson()
+      const = 0;
 
  protected:
   virtual ~State() = default;
diff --git a/libweave/src/base_api_handler_unittest.cc b/libweave/src/base_api_handler_unittest.cc
index 3e35bd9..46b80f7 100644
--- a/libweave/src/base_api_handler_unittest.cc
+++ b/libweave/src/base_api_handler_unittest.cc
@@ -124,7 +124,7 @@
       'network': {}
     }
   })";
-  EXPECT_JSON_EQ(expected, *state_manager_->GetStateValuesAsJson(nullptr));
+  EXPECT_JSON_EQ(expected, *state_manager_->GetStateValuesAsJson());
 
   AddCommand(R"({
     'name' : 'base.updateBaseConfiguration',
@@ -146,7 +146,7 @@
       'network': {}
     }
   })";
-  EXPECT_JSON_EQ(expected, *state_manager_->GetStateValuesAsJson(nullptr));
+  EXPECT_JSON_EQ(expected, *state_manager_->GetStateValuesAsJson());
 }
 
 TEST_F(BaseApiHandlerTest, UpdateDeviceInfo) {
diff --git a/libweave/src/commands/command_dictionary.cc b/libweave/src/commands/command_dictionary.cc
index 536c7fc..8359be5 100644
--- a/libweave/src/commands/command_dictionary.cc
+++ b/libweave/src/commands/command_dictionary.cc
@@ -222,9 +222,8 @@
       continue;
 
     std::unique_ptr<base::DictionaryValue> parameters =
-        pair.second->GetParameters()->ToJson(full_schema, true, error);
-    if (!parameters)
-      return {};
+        pair.second->GetParameters()->ToJson(full_schema, true);
+    CHECK(parameters);
     // Progress and results are not part of public commandDefs.
 
     auto cmd_name_parts = chromeos::string_utils::SplitAtFirst(pair.first, ".");
diff --git a/libweave/src/commands/command_dictionary_unittest.cc b/libweave/src/commands/command_dictionary_unittest.cc
index 093aee3..5348777 100644
--- a/libweave/src/commands/command_dictionary_unittest.cc
+++ b/libweave/src/commands/command_dictionary_unittest.cc
@@ -92,11 +92,11 @@
   EXPECT_EQ(UserRole::kViewer, cmd->GetMinimalRole());
 
   EXPECT_JSON_EQ("{'height': {'type': 'integer'}}",
-                 *cmd->GetParameters()->ToJson(true, true, nullptr));
+                 *cmd->GetParameters()->ToJson(true, true));
   EXPECT_JSON_EQ("{'progress': {'type': 'integer'}}",
-                 *cmd->GetProgress()->ToJson(true, false, nullptr));
+                 *cmd->GetProgress()->ToJson(true, false));
   EXPECT_JSON_EQ("{'success': {'type': 'boolean'}}",
-                 *cmd->GetResults()->ToJson(true, false, nullptr));
+                 *cmd->GetResults()->ToJson(true, false));
 }
 
 TEST(CommandDictionary, LoadCommands_Failures) {
diff --git a/libweave/src/commands/command_instance.cc b/libweave/src/commands/command_instance.cc
index d2efcb4..8c4b89a 100644
--- a/libweave/src/commands/command_instance.cc
+++ b/libweave/src/commands/command_instance.cc
@@ -83,15 +83,15 @@
 }
 
 std::unique_ptr<base::DictionaryValue> CommandInstance::GetParameters() const {
-  return TypedValueToJson(parameters_, nullptr);
+  return TypedValueToJson(parameters_);
 }
 
 std::unique_ptr<base::DictionaryValue> CommandInstance::GetProgress() const {
-  return TypedValueToJson(progress_, nullptr);
+  return TypedValueToJson(progress_);
 }
 
 std::unique_ptr<base::DictionaryValue> CommandInstance::GetResults() const {
-  return TypedValueToJson(results_, nullptr);
+  return TypedValueToJson(results_);
 }
 
 bool CommandInstance::SetProgress(const base::DictionaryValue& progress,
@@ -240,11 +240,11 @@
   json->SetString(commands::attributes::kCommand_Id, id_);
   json->SetString(commands::attributes::kCommand_Name, name_);
   json->Set(commands::attributes::kCommand_Parameters,
-            TypedValueToJson(parameters_, nullptr).release());
+            TypedValueToJson(parameters_).release());
   json->Set(commands::attributes::kCommand_Progress,
-            TypedValueToJson(progress_, nullptr).release());
+            TypedValueToJson(progress_).release());
   json->Set(commands::attributes::kCommand_Results,
-            TypedValueToJson(results_, nullptr).release());
+            TypedValueToJson(results_).release());
   json->SetString(commands::attributes::kCommand_State, EnumToString(status_));
 
   return json;
diff --git a/libweave/src/commands/object_schema.cc b/libweave/src/commands/object_schema.cc
index 1f7b7fa..f117b6b 100644
--- a/libweave/src/commands/object_schema.cc
+++ b/libweave/src/commands/object_schema.cc
@@ -299,16 +299,15 @@
   p->second->MakeRequired(true);
   return true;
 }
+
 std::unique_ptr<base::DictionaryValue> ObjectSchema::ToJson(
     bool full_schema,
-    bool in_command_def,
-    chromeos::ErrorPtr* error) const {
+    bool in_command_def) const {
   std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue);
   for (const auto& pair : properties_) {
-    auto PropDef = pair.second->ToJson(full_schema, in_command_def, error);
-    if (!PropDef)
-      return {};
-    value->SetWithoutPathExpansion(pair.first, PropDef.release());
+    auto prop_def = pair.second->ToJson(full_schema, in_command_def);
+    CHECK(prop_def);
+    value->SetWithoutPathExpansion(pair.first, prop_def.release());
   }
   return value;
 }
diff --git a/libweave/src/commands/object_schema.h b/libweave/src/commands/object_schema.h
index 51c555f..b971dd8 100644
--- a/libweave/src/commands/object_schema.h
+++ b/libweave/src/commands/object_schema.h
@@ -67,10 +67,8 @@
   // Saves the object schema to JSON. When |full_schema| is set to true,
   // then all properties and constraints are saved, otherwise, only
   // the overridden (not inherited) ones are saved.
-  std::unique_ptr<base::DictionaryValue> ToJson(
-      bool full_schema,
-      bool in_command_def,
-      chromeos::ErrorPtr* error) const;
+  std::unique_ptr<base::DictionaryValue> ToJson(bool full_schema,
+                                                bool in_command_def) const;
 
   // Loads the object schema from JSON. If |object_schema| is not nullptr, it is
   // used as a base schema to inherit omitted properties and constraints from.
diff --git a/libweave/src/commands/object_schema_unittest.cc b/libweave/src/commands/object_schema_unittest.cc
index d927c7b..1bb8e01 100644
--- a/libweave/src/commands/object_schema_unittest.cc
+++ b/libweave/src/commands/object_schema_unittest.cc
@@ -68,26 +68,25 @@
 
 TEST(CommandSchema, IntPropType_ToJson) {
   IntPropType prop;
-  EXPECT_JSON_EQ("'integer'", *prop.ToJson(false, false, nullptr));
-  EXPECT_JSON_EQ("{'type':'integer'}", *prop.ToJson(true, false, nullptr));
+  EXPECT_JSON_EQ("'integer'", *prop.ToJson(false, false));
+  EXPECT_JSON_EQ("{'type':'integer'}", *prop.ToJson(true, false));
   IntPropType param2;
   param2.FromJson(CreateDictionaryValue("{}").get(), &prop, nullptr);
-  EXPECT_JSON_EQ("{}", *param2.ToJson(false, false, nullptr));
+  EXPECT_JSON_EQ("{}", *param2.ToJson(false, false));
   param2.FromJson(CreateDictionaryValue("{'minimum':3}").get(), &prop, nullptr);
-  EXPECT_JSON_EQ("{'minimum':3}", *param2.ToJson(false, false, nullptr));
+  EXPECT_JSON_EQ("{'minimum':3}", *param2.ToJson(false, false));
   param2.FromJson(CreateDictionaryValue("{'maximum':-7}").get(), &prop,
                   nullptr);
-  EXPECT_JSON_EQ("{'maximum':-7}", *param2.ToJson(false, false, nullptr));
+  EXPECT_JSON_EQ("{'maximum':-7}", *param2.ToJson(false, false));
   param2.FromJson(CreateDictionaryValue("{'minimum':0,'maximum':5}").get(),
                   &prop, nullptr);
-  EXPECT_JSON_EQ("{'maximum':5,'minimum':0}",
-                 *param2.ToJson(false, false, nullptr));
+  EXPECT_JSON_EQ("{'maximum':5,'minimum':0}", *param2.ToJson(false, false));
   param2.FromJson(CreateDictionaryValue("{'enum':[1,2,3]}").get(), &prop,
                   nullptr);
-  EXPECT_JSON_EQ("[1,2,3]", *param2.ToJson(false, false, nullptr));
+  EXPECT_JSON_EQ("[1,2,3]", *param2.ToJson(false, false));
   param2.FromJson(CreateDictionaryValue("{'default':123}").get(), &prop,
                   nullptr);
-  EXPECT_JSON_EQ("{'default':123}", *param2.ToJson(false, false, nullptr));
+  EXPECT_JSON_EQ("{'default':123}", *param2.ToJson(false, false));
 }
 
 TEST(CommandSchema, IntPropType_FromJson) {
@@ -188,19 +187,19 @@
 
 TEST(CommandSchema, BoolPropType_ToJson) {
   BooleanPropType prop;
-  EXPECT_JSON_EQ("'boolean'", *prop.ToJson(false, false, nullptr));
-  EXPECT_JSON_EQ("{'type':'boolean'}", *prop.ToJson(true, false, nullptr));
+  EXPECT_JSON_EQ("'boolean'", *prop.ToJson(false, false));
+  EXPECT_JSON_EQ("{'type':'boolean'}", *prop.ToJson(true, false));
   BooleanPropType param2;
   param2.FromJson(CreateDictionaryValue("{}").get(), &prop, nullptr);
-  EXPECT_JSON_EQ("{}", *param2.ToJson(false, false, nullptr));
+  EXPECT_JSON_EQ("{}", *param2.ToJson(false, false));
   param2.FromJson(CreateDictionaryValue("{'enum':[true,false]}").get(), &prop,
                   nullptr);
-  EXPECT_JSON_EQ("[true,false]", *param2.ToJson(false, false, nullptr));
+  EXPECT_JSON_EQ("[true,false]", *param2.ToJson(false, false));
   EXPECT_JSON_EQ("{'enum':[true,false],'type':'boolean'}",
-                 *param2.ToJson(true, false, nullptr));
+                 *param2.ToJson(true, false));
   param2.FromJson(CreateDictionaryValue("{'default':true}").get(), &prop,
                   nullptr);
-  EXPECT_JSON_EQ("{'default':true}", *param2.ToJson(false, false, nullptr));
+  EXPECT_JSON_EQ("{'default':true}", *param2.ToJson(false, false));
 }
 
 TEST(CommandSchema, BoolPropType_FromJson) {
@@ -278,23 +277,22 @@
 
 TEST(CommandSchema, DoublePropType_ToJson) {
   DoublePropType prop;
-  EXPECT_JSON_EQ("'number'", *prop.ToJson(false, false, nullptr));
-  EXPECT_JSON_EQ("{'type':'number'}", *prop.ToJson(true, false, nullptr));
+  EXPECT_JSON_EQ("'number'", *prop.ToJson(false, false));
+  EXPECT_JSON_EQ("{'type':'number'}", *prop.ToJson(true, false));
   DoublePropType param2;
   param2.FromJson(CreateDictionaryValue("{}").get(), &prop, nullptr);
-  EXPECT_JSON_EQ("{}", *param2.ToJson(false, false, nullptr));
+  EXPECT_JSON_EQ("{}", *param2.ToJson(false, false));
   param2.FromJson(CreateDictionaryValue("{'minimum':3}").get(), &prop, nullptr);
-  EXPECT_JSON_EQ("{'minimum':3.0}", *param2.ToJson(false, false, nullptr));
+  EXPECT_JSON_EQ("{'minimum':3.0}", *param2.ToJson(false, false));
   param2.FromJson(CreateDictionaryValue("{'maximum':-7}").get(), &prop,
                   nullptr);
-  EXPECT_JSON_EQ("{'maximum':-7.0}", *param2.ToJson(false, false, nullptr));
+  EXPECT_JSON_EQ("{'maximum':-7.0}", *param2.ToJson(false, false));
   param2.FromJson(CreateDictionaryValue("{'minimum':0,'maximum':5}").get(),
                   &prop, nullptr);
-  EXPECT_JSON_EQ("{'maximum':5.0,'minimum':0.0}",
-                 *param2.ToJson(false, false, nullptr));
+  EXPECT_JSON_EQ("{'maximum':5.0,'minimum':0.0}", *param2.ToJson(false, false));
   param2.FromJson(CreateDictionaryValue("{'default':12.3}").get(), &prop,
                   nullptr);
-  EXPECT_JSON_EQ("{'default':12.3}", *param2.ToJson(false, false, nullptr));
+  EXPECT_JSON_EQ("{'default':12.3}", *param2.ToJson(false, false));
 }
 
 TEST(CommandSchema, DoublePropType_FromJson) {
@@ -396,24 +394,23 @@
 
 TEST(CommandSchema, StringPropType_ToJson) {
   StringPropType prop;
-  EXPECT_JSON_EQ("'string'", *prop.ToJson(false, false, nullptr));
-  EXPECT_JSON_EQ("{'type':'string'}", *prop.ToJson(true, false, nullptr));
+  EXPECT_JSON_EQ("'string'", *prop.ToJson(false, false));
+  EXPECT_JSON_EQ("{'type':'string'}", *prop.ToJson(true, false));
   StringPropType param2;
   param2.FromJson(CreateDictionaryValue("{}").get(), &prop, nullptr);
-  EXPECT_JSON_EQ("{}", *param2.ToJson(false, false, nullptr));
+  EXPECT_JSON_EQ("{}", *param2.ToJson(false, false));
   param2.FromJson(CreateDictionaryValue("{'minLength':3}").get(), &prop,
                   nullptr);
-  EXPECT_JSON_EQ("{'minLength':3}", *param2.ToJson(false, false, nullptr));
+  EXPECT_JSON_EQ("{'minLength':3}", *param2.ToJson(false, false));
   param2.FromJson(CreateDictionaryValue("{'maxLength':7}").get(), &prop,
                   nullptr);
-  EXPECT_JSON_EQ("{'maxLength':7}", *param2.ToJson(false, false, nullptr));
+  EXPECT_JSON_EQ("{'maxLength':7}", *param2.ToJson(false, false));
   param2.FromJson(CreateDictionaryValue("{'minLength':0,'maxLength':5}").get(),
                   &prop, nullptr);
-  EXPECT_JSON_EQ("{'maxLength':5,'minLength':0}",
-                 *param2.ToJson(false, false, nullptr));
+  EXPECT_JSON_EQ("{'maxLength':5,'minLength':0}", *param2.ToJson(false, false));
   param2.FromJson(CreateDictionaryValue("{'default':'abcd'}").get(), &prop,
                   nullptr);
-  EXPECT_JSON_EQ("{'default':'abcd'}", *param2.ToJson(false, false, nullptr));
+  EXPECT_JSON_EQ("{'default':'abcd'}", *param2.ToJson(false, false));
 }
 
 TEST(CommandSchema, StringPropType_FromJson) {
@@ -521,14 +518,14 @@
 TEST(CommandSchema, ObjectPropType_ToJson) {
   ObjectPropType prop;
   EXPECT_JSON_EQ("{'additionalProperties':false,'properties':{}}",
-                 *prop.ToJson(false, false, nullptr));
+                 *prop.ToJson(false, false));
   EXPECT_JSON_EQ(
       "{'additionalProperties':false,'properties':{},'type':'object'}",
-      *prop.ToJson(true, false, nullptr));
+      *prop.ToJson(true, false));
   EXPECT_FALSE(prop.IsBasedOnSchema());
   ObjectPropType prop2;
   prop2.FromJson(CreateDictionaryValue("{}").get(), &prop, nullptr);
-  EXPECT_JSON_EQ("{}", *prop2.ToJson(false, false, nullptr));
+  EXPECT_JSON_EQ("{}", *prop2.ToJson(false, false));
   EXPECT_TRUE(prop2.IsBasedOnSchema());
 
   auto schema = ObjectSchema::Create();
@@ -547,7 +544,7 @@
       }
     }
   })";
-  EXPECT_JSON_EQ(expected, *prop2.ToJson(false, false, nullptr));
+  EXPECT_JSON_EQ(expected, *prop2.ToJson(false, false));
 
   expected = R"({
     'additionalProperties': false,
@@ -563,7 +560,7 @@
     },
     'type': 'object'
   })";
-  EXPECT_JSON_EQ(expected, *prop2.ToJson(true, false, nullptr));
+  EXPECT_JSON_EQ(expected, *prop2.ToJson(true, false));
 
   ObjectPropType prop3;
   ASSERT_TRUE(
@@ -577,7 +574,7 @@
       'password': 'abracadabra'
     }
   })";
-  EXPECT_JSON_EQ(expected, *prop3.ToJson(false, false, nullptr));
+  EXPECT_JSON_EQ(expected, *prop3.ToJson(false, false));
 
   expected = R"({
     'additionalProperties': false,
@@ -597,7 +594,7 @@
     },
     'type': 'object'
   })";
-  EXPECT_JSON_EQ(expected, *prop3.ToJson(true, false, nullptr));
+  EXPECT_JSON_EQ(expected, *prop3.ToJson(true, false));
 
   ObjectPropType prop4;
   ASSERT_TRUE(
@@ -620,7 +617,7 @@
       }
     }
   })";
-  EXPECT_JSON_EQ(expected, *prop4.ToJson(false, false, nullptr));
+  EXPECT_JSON_EQ(expected, *prop4.ToJson(false, false));
 
   expected = R"({
     'additionalProperties': true,
@@ -640,7 +637,7 @@
     },
     'type': 'object'
   })";
-  EXPECT_JSON_EQ(expected, *prop4.ToJson(true, false, nullptr));
+  EXPECT_JSON_EQ(expected, *prop4.ToJson(true, false));
 }
 
 TEST(CommandSchema, ObjectPropType_FromJson) {
@@ -784,20 +781,20 @@
 TEST(CommandSchema, ArrayPropType_ToJson) {
   ArrayPropType prop;
   prop.SetItemType(PropType::Create(ValueType::Int));
-  EXPECT_JSON_EQ("{'items':'integer'}", *prop.ToJson(false, false, nullptr));
+  EXPECT_JSON_EQ("{'items':'integer'}", *prop.ToJson(false, false));
   EXPECT_JSON_EQ("{'items':{'type':'integer'},'type':'array'}",
-                 *prop.ToJson(true, false, nullptr));
+                 *prop.ToJson(true, false));
   EXPECT_FALSE(prop.IsBasedOnSchema());
   ArrayPropType prop2;
   prop2.FromJson(CreateDictionaryValue("{}").get(), &prop, nullptr);
-  EXPECT_JSON_EQ("{}", *prop2.ToJson(false, false, nullptr));
+  EXPECT_JSON_EQ("{}", *prop2.ToJson(false, false));
   EXPECT_TRUE(prop2.IsBasedOnSchema());
   prop2.FromJson(CreateDictionaryValue("{'default':[1,2,3]}").get(), &prop,
                  nullptr);
-  EXPECT_JSON_EQ("{'default':[1,2,3]}", *prop2.ToJson(false, false, nullptr));
+  EXPECT_JSON_EQ("{'default':[1,2,3]}", *prop2.ToJson(false, false));
   EXPECT_JSON_EQ(
       "{'default':[1,2,3],'items':{'type':'integer'},'type':'array'}",
-      *prop2.ToJson(true, false, nullptr));
+      *prop2.ToJson(true, false));
 }
 
 TEST(CommandSchema, ArrayPropType_FromJson) {
@@ -879,7 +876,7 @@
   ASSERT_NE(nullptr, val.get());
   EXPECT_EQ(nullptr, error.get());
   EXPECT_EQ(arr, val->GetValueAsAny().Get<ValueVector>());
-  EXPECT_JSON_EQ("[]", *val->ToJson(nullptr));
+  EXPECT_JSON_EQ("[]", *val->ToJson());
 
   IntPropType int_type;
   ObjectPropType obj_type;
@@ -906,7 +903,7 @@
   EXPECT_EQ(nullptr, error.get());
   EXPECT_EQ(arr, val->GetValueAsAny().Get<ValueVector>());
   EXPECT_JSON_EQ("[{'height':20,'width':10},{'height':18,'width':17}]",
-                 *val->ToJson(nullptr));
+                 *val->ToJson());
 
   val = prop.CreateValue("blah", &error);
   EXPECT_EQ(nullptr, val.get());
@@ -1484,14 +1481,14 @@
   IntPropType prop;
 
   prop.MakeRequired(false);
-  EXPECT_JSON_EQ("{'type':'integer'}", *prop.ToJson(true, false, nullptr));
+  EXPECT_JSON_EQ("{'type':'integer'}", *prop.ToJson(true, false));
   EXPECT_JSON_EQ("{'isRequired':false,'type':'integer'}",
-                 *prop.ToJson(true, true, nullptr));
+                 *prop.ToJson(true, true));
 
   prop.MakeRequired(true);
-  EXPECT_JSON_EQ("{'type':'integer'}", *prop.ToJson(true, false, nullptr));
+  EXPECT_JSON_EQ("{'type':'integer'}", *prop.ToJson(true, false));
   EXPECT_JSON_EQ("{'isRequired':true,'type':'integer'}",
-                 *prop.ToJson(true, true, nullptr));
+                 *prop.ToJson(true, true));
 
   IntPropType prop2;
   EXPECT_TRUE(prop2.FromJson(CreateDictionaryValue("{}").get(), &prop,
@@ -1502,9 +1499,9 @@
       CreateDictionaryValue("{'isRequired': false}").get(), &prop, nullptr));
   EXPECT_FALSE(prop2.IsRequired());
 
-  EXPECT_JSON_EQ("{'type':'integer'}", *prop2.ToJson(true, false, nullptr));
+  EXPECT_JSON_EQ("{'type':'integer'}", *prop2.ToJson(true, false));
   EXPECT_JSON_EQ("{'isRequired':false,'type':'integer'}",
-                 *prop2.ToJson(true, true, nullptr));
+                 *prop2.ToJson(true, true));
 }
 
 TEST(CommandSchema, RequiredProperties_Object) {
@@ -1528,14 +1525,14 @@
     'prop3': 'boolean',
     'prop4': {'items': 'string'}
   })";
-  EXPECT_JSON_EQ(expected1, *schema->ToJson(false, false, nullptr));
+  EXPECT_JSON_EQ(expected1, *schema->ToJson(false, false));
   auto expected2 = R"({
     'prop1': {'type':'integer','isRequired': true},
     'prop2': {'type':'string','isRequired': false},
     'prop3': {'type':'boolean','isRequired': true},
     'prop4': {'items': 'string'}
   })";
-  EXPECT_JSON_EQ(expected2, *schema->ToJson(false, true, nullptr));
+  EXPECT_JSON_EQ(expected2, *schema->ToJson(false, true));
 
   obj_type.SetObjectSchema(std::move(schema));
   auto expected3 = R"({
@@ -1548,8 +1545,8 @@
     },
     'required': ['prop1','prop3']
   })";
-  EXPECT_JSON_EQ(expected3, *obj_type.ToJson(false, false, nullptr));
-  EXPECT_JSON_EQ(expected3, *obj_type.ToJson(false, true, nullptr));
+  EXPECT_JSON_EQ(expected3, *obj_type.ToJson(false, false));
+  EXPECT_JSON_EQ(expected3, *obj_type.ToJson(false, true));
 }
 
 TEST(CommandSchema, RequiredProperties_Schema_FromJson) {
@@ -1564,7 +1561,7 @@
   EXPECT_TRUE(schema.GetProp("prop1")->IsRequired());
   EXPECT_FALSE(schema.GetProp("prop2")->IsRequired());
   EXPECT_FALSE(schema.GetProp("prop3")->IsRequired());
-  EXPECT_JSON_EQ(schema_str, *schema.ToJson(false, true, nullptr));
+  EXPECT_JSON_EQ(schema_str, *schema.ToJson(false, true));
 }
 
 TEST(CommandSchema, RequiredProperties_Schema_FromJson_Inherit) {
@@ -1596,7 +1593,7 @@
     'prop3': {},
     'prop4': {}
   })";
-  EXPECT_JSON_EQ(expected, *schema.ToJson(false, true, nullptr));
+  EXPECT_JSON_EQ(expected, *schema.ToJson(false, true));
 }
 
 TEST(CommandSchema, RequiredProperties_ObjectPropType_FromJson) {
diff --git a/libweave/src/commands/prop_constraints.cc b/libweave/src/commands/prop_constraints.cc
index 9d9f81e..4f730f7 100644
--- a/libweave/src/commands/prop_constraints.cc
+++ b/libweave/src/commands/prop_constraints.cc
@@ -17,9 +17,9 @@
 // error reporting.
 std::string PropValueToString(const PropValue& value) {
   std::string result;
-  auto json = value.ToJson(nullptr);
-  if (json)
-    base::JSONWriter::Write(*json, &result);
+  auto json = value.ToJson();
+  CHECK(json);
+  base::JSONWriter::Write(*json, &result);
   return result;
 }
 
@@ -62,16 +62,13 @@
   return false;
 }
 
-bool Constraint::AddToJsonDict(base::DictionaryValue* dict,
-                               bool overridden_only,
-                               chromeos::ErrorPtr* error) const {
+void Constraint::AddToJsonDict(base::DictionaryValue* dict,
+                               bool overridden_only) const {
   if (!overridden_only || HasOverriddenAttributes()) {
-    auto value = ToJson(error);
-    if (!value)
-      return false;
+    auto value = ToJson();
+    CHECK(value);
     dict->SetWithoutPathExpansion(GetDictKey(), value.release());
   }
-  return true;
 }
 
 // ConstraintStringLength -----------------------------------------------------
@@ -86,9 +83,8 @@
   return !limit_.is_inherited;
 }
 
-std::unique_ptr<base::Value> ConstraintStringLength::ToJson(
-    chromeos::ErrorPtr* error) const {
-  return TypedValueToJson(limit_.value, error);
+std::unique_ptr<base::Value> ConstraintStringLength::ToJson() const {
+  return TypedValueToJson(limit_.value);
 }
 
 // ConstraintStringLengthMin --------------------------------------------------
@@ -205,9 +201,8 @@
   return std::unique_ptr<Constraint>{new ConstraintOneOf{std::move(cloned)}};
 }
 
-std::unique_ptr<base::Value> ConstraintOneOf::ToJson(
-    chromeos::ErrorPtr* error) const {
-  return TypedValueToJson(set_.value, error);
+std::unique_ptr<base::Value> ConstraintOneOf::ToJson() const {
+  return TypedValueToJson(set_.value);
 }
 
 const char* ConstraintOneOf::GetDictKey() const {
diff --git a/libweave/src/commands/prop_constraints.h b/libweave/src/commands/prop_constraints.h
index d325a00..80ecbb9 100644
--- a/libweave/src/commands/prop_constraints.h
+++ b/libweave/src/commands/prop_constraints.h
@@ -55,17 +55,15 @@
   // Saves the constraint into the specified JSON |dict| object, representing
   // the object schema. If |overridden_only| is set to true, then the
   // inherited constraints will not be added to the schema object.
-  virtual bool AddToJsonDict(base::DictionaryValue* dict,
-                             bool overridden_only,
-                             chromeos::ErrorPtr* error) const;
+  virtual void AddToJsonDict(base::DictionaryValue* dict,
+                             bool overridden_only) const;
 
   // Saves the value of constraint to JSON value. E.g., if the numeric
   // constraint was defined as {"minimum":20} this will create a JSON value
   // of 20. The current design implies that each constraint has one value
   // only. If this assumption changes, this interface needs to be updated
   // accordingly.
-  virtual std::unique_ptr<base::Value> ToJson(
-      chromeos::ErrorPtr* error) const = 0;
+  virtual std::unique_ptr<base::Value> ToJson() const = 0;
 
   // Overloaded by the concrete class implementation, it should return the
   // JSON object property name to store the constraint's value as.
@@ -107,9 +105,8 @@
   bool HasOverriddenAttributes() const override { return !limit_.is_inherited; }
 
   // Implementation of Constraint::ToJson().
-  std::unique_ptr<base::Value> ToJson(
-      chromeos::ErrorPtr* error) const override {
-    return TypedValueToJson(limit_.value, error);
+  std::unique_ptr<base::Value> ToJson() const override {
+    return TypedValueToJson(limit_.value);
   }
 
   // Stores the upper/lower value limit for maximum/minimum constraint.
@@ -213,7 +210,7 @@
   // Implementation of Constraint::HasOverriddenAttributes().
   bool HasOverriddenAttributes() const override;
   // Implementation of Constraint::ToJson().
-  std::unique_ptr<base::Value> ToJson(chromeos::ErrorPtr* error) const override;
+  std::unique_ptr<base::Value> ToJson() const override;
 
   // Stores the upper/lower value limit for string length constraint.
   // |limit_.is_inherited| indicates whether the constraint is inherited
@@ -306,7 +303,7 @@
   std::unique_ptr<Constraint> CloneAsInherited() const override;
 
   // Implementation of Constraint::ToJson().
-  std::unique_ptr<base::Value> ToJson(chromeos::ErrorPtr* error) const override;
+  std::unique_ptr<base::Value> ToJson() const override;
 
   // Implementation of Constraint::GetDictKey().
   const char* GetDictKey() const override;
diff --git a/libweave/src/commands/prop_types.cc b/libweave/src/commands/prop_types.cc
index 3105e6d..ffec8f4 100644
--- a/libweave/src/commands/prop_types.cc
+++ b/libweave/src/commands/prop_types.cc
@@ -52,8 +52,7 @@
 }
 
 std::unique_ptr<base::Value> PropType::ToJson(bool full_schema,
-                                              bool in_command_def,
-                                              chromeos::ErrorPtr* error) const {
+                                              bool in_command_def) const {
   // Determine if we need to output "isRequired" attribute.
   const bool include_required = in_command_def && !required_.is_inherited;
 
@@ -66,7 +65,7 @@
   if (!full_schema && !HasOverriddenAttributes()) {
     if (based_on_schema_)
       return std::unique_ptr<base::Value>(new base::DictionaryValue);
-    return TypedValueToJson(GetTypeAsString(), error);
+    return TypedValueToJson(GetTypeAsString());
   }
 
   std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
@@ -93,20 +92,17 @@
     // {'enum':[1,2,3]}
     auto p = constraints_.find(ConstraintType::OneOf);
     if (p != constraints_.end()) {
-      return p->second->ToJson(error);
+      return p->second->ToJson();
     }
   }
 
-  for (const auto& pair : constraints_) {
-    if (!pair.second->AddToJsonDict(dict.get(), !full_schema, error))
-      return std::unique_ptr<base::Value>();
-  }
+  for (const auto& pair : constraints_)
+    pair.second->AddToJsonDict(dict.get(), !full_schema);
 
   if (default_.value && (full_schema || !default_.is_inherited)) {
-    auto defval = default_.value->ToJson(error);
-    if (!defval)
-      return std::unique_ptr<base::Value>();
-    dict->Set(commands::attributes::kDefault, defval.release());
+    auto def_val = default_.value->ToJson();
+    CHECK(def_val);
+    dict->Set(commands::attributes::kDefault, def_val.release());
   }
 
   if (include_required)
@@ -495,35 +491,29 @@
   return cloned;
 }
 
-std::unique_ptr<base::Value> ObjectPropType::ToJson(
-    bool full_schema,
-    bool in_command_def,
-    chromeos::ErrorPtr* error) const {
+std::unique_ptr<base::Value> ObjectPropType::ToJson(bool full_schema,
+                                                    bool in_command_def) const {
   std::unique_ptr<base::Value> value =
-      PropType::ToJson(full_schema, in_command_def, error);
-  if (value) {
-    base::DictionaryValue* dict = nullptr;
-    CHECK(value->GetAsDictionary(&dict)) << "Expecting a JSON object";
-    if (!object_schema_.is_inherited || full_schema) {
-      auto object_schema =
-          object_schema_.value->ToJson(full_schema, false, error);
-      if (!object_schema) {
-        value.reset();
-        return value;
-      }
-      dict->SetWithoutPathExpansion(commands::attributes::kObject_Properties,
-                                    object_schema.release());
-      dict->SetBooleanWithoutPathExpansion(
-          commands::attributes::kObject_AdditionalProperties,
-          object_schema_.value->GetExtraPropertiesAllowed());
-      std::unique_ptr<base::ListValue> required{new base::ListValue};
-      for (const auto& pair : object_schema_.value->GetProps()) {
-        if (pair.second->IsRequired())
-          required->AppendString(pair.first);
-      }
-      if (required->GetSize() > 0) {
-        dict->Set(commands::attributes::kObject_Required, required.release());
-      }
+      PropType::ToJson(full_schema, in_command_def);
+  CHECK(value);
+  base::DictionaryValue* dict = nullptr;
+  CHECK(value->GetAsDictionary(&dict)) << "Expecting a JSON object";
+  if (!object_schema_.is_inherited || full_schema) {
+    auto object_schema = object_schema_.value->ToJson(full_schema, false);
+    CHECK(object_schema);
+
+    dict->SetWithoutPathExpansion(commands::attributes::kObject_Properties,
+                                  object_schema.release());
+    dict->SetBooleanWithoutPathExpansion(
+        commands::attributes::kObject_AdditionalProperties,
+        object_schema_.value->GetExtraPropertiesAllowed());
+    std::unique_ptr<base::ListValue> required{new base::ListValue};
+    for (const auto& pair : object_schema_.value->GetProps()) {
+      if (pair.second->IsRequired())
+        required->AppendString(pair.first);
+    }
+    if (required->GetSize() > 0) {
+      dict->Set(commands::attributes::kObject_Required, required.release());
     }
   }
   return value;
@@ -660,22 +650,17 @@
   return cloned;
 }
 
-std::unique_ptr<base::Value> ArrayPropType::ToJson(
-    bool full_schema,
-    bool in_command_def,
-    chromeos::ErrorPtr* error) const {
+std::unique_ptr<base::Value> ArrayPropType::ToJson(bool full_schema,
+                                                   bool in_command_def) const {
   std::unique_ptr<base::Value> value =
-      PropType::ToJson(full_schema, in_command_def, error);
-  if (value && (!item_type_.is_inherited || full_schema)) {
+      PropType::ToJson(full_schema, in_command_def);
+  CHECK(value);
+  if (!item_type_.is_inherited || full_schema) {
     base::DictionaryValue* dict = nullptr;
     CHECK(value->GetAsDictionary(&dict)) << "Expecting a JSON object";
-    auto type = item_type_.value->ToJson(full_schema, false, error);
-      if (!type) {
-        value.reset();
-        return value;
-      }
-      dict->SetWithoutPathExpansion(commands::attributes::kItems,
-                                    type.release());
+    auto type = item_type_.value->ToJson(full_schema, false);
+    CHECK(type);
+    dict->SetWithoutPathExpansion(commands::attributes::kItems, type.release());
   }
   return value;
 }
diff --git a/libweave/src/commands/prop_types.h b/libweave/src/commands/prop_types.h
index 09420f1..eb605a7 100644
--- a/libweave/src/commands/prop_types.h
+++ b/libweave/src/commands/prop_types.h
@@ -121,8 +121,7 @@
   // Command definitions handle required parameters differently (using
   // "isRequired" property as opposed to "required" list for object properties).
   virtual std::unique_ptr<base::Value> ToJson(bool full_schema,
-                                              bool in_command_def,
-                                              chromeos::ErrorPtr* error) const;
+                                              bool in_command_def) const;
   // Parses an JSON parameter type definition. Optional |base_schema| may
   // specify the base schema type definition this type should be based upon.
   // If not specified (nullptr), the parameter type is assumed to be a full
@@ -363,8 +362,7 @@
   std::unique_ptr<PropType> Clone() const override;
 
   std::unique_ptr<base::Value> ToJson(bool full_schema,
-                                      bool in_command_def,
-                                      chromeos::ErrorPtr* error) const override;
+                                      bool in_command_def) const override;
   bool ObjectSchemaFromJson(const base::DictionaryValue* value,
                             const PropType* base_schema,
                             std::set<std::string>* processed_keys,
@@ -403,8 +401,7 @@
   std::unique_ptr<PropType> Clone() const override;
 
   std::unique_ptr<base::Value> ToJson(bool full_schema,
-                                      bool in_command_def,
-                                      chromeos::ErrorPtr* error) const override;
+                                      bool in_command_def) const override;
 
   bool ObjectSchemaFromJson(const base::DictionaryValue* value,
                             const PropType* base_schema,
diff --git a/libweave/src/commands/prop_values.h b/libweave/src/commands/prop_values.h
index 4740a3f..d0b2dc7 100644
--- a/libweave/src/commands/prop_values.h
+++ b/libweave/src/commands/prop_values.h
@@ -112,11 +112,8 @@
   // Makes a full copy of this value class.
   virtual std::unique_ptr<PropValue> Clone() const = 0;
 
-  // Saves the value as a JSON object.
-  // If it fails, returns nullptr value and fills in the details for the
-  // failure in the |error| parameter.
-  virtual std::unique_ptr<base::Value> ToJson(
-      chromeos::ErrorPtr* error) const = 0;
+  // Saves the value as a JSON object. Never fails.
+  virtual std::unique_ptr<base::Value> ToJson() const = 0;
   // Parses a value from JSON.
   // If it fails, it returns false and provides additional information
   // via the |error| parameter.
@@ -154,9 +151,8 @@
     return std::move(derived);
   }
 
-  std::unique_ptr<base::Value> ToJson(
-      chromeos::ErrorPtr* error) const override {
-    return TypedValueToJson(value_, error);
+  std::unique_ptr<base::Value> ToJson() const override {
+    return TypedValueToJson(value_);
   }
 
   bool FromJson(const base::Value* value, chromeos::ErrorPtr* error) override {
diff --git a/libweave/src/commands/schema_utils.cc b/libweave/src/commands/schema_utils.cc
index a171109..04b8bcb 100644
--- a/libweave/src/commands/schema_utils.cc
+++ b/libweave/src/commands/schema_utils.cc
@@ -55,52 +55,40 @@
 }  // namespace
 
 // Specializations of TypedValueToJson<T>() for supported C++ types.
-std::unique_ptr<base::FundamentalValue> TypedValueToJson(
-    bool value,
-    chromeos::ErrorPtr* error) {
+std::unique_ptr<base::FundamentalValue> TypedValueToJson(bool value) {
   return std::unique_ptr<base::FundamentalValue>(
       new base::FundamentalValue(value));
 }
 
-std::unique_ptr<base::FundamentalValue> TypedValueToJson(
-    int value,
-    chromeos::ErrorPtr* error) {
+std::unique_ptr<base::FundamentalValue> TypedValueToJson(int value) {
   return std::unique_ptr<base::FundamentalValue>(
       new base::FundamentalValue(value));
 }
 
-std::unique_ptr<base::FundamentalValue> TypedValueToJson(
-    double value,
-    chromeos::ErrorPtr* error) {
+std::unique_ptr<base::FundamentalValue> TypedValueToJson(double value) {
   return std::unique_ptr<base::FundamentalValue>(
       new base::FundamentalValue(value));
 }
 
-std::unique_ptr<base::StringValue> TypedValueToJson(const std::string& value,
-                                                    chromeos::ErrorPtr* error) {
+std::unique_ptr<base::StringValue> TypedValueToJson(const std::string& value) {
   return std::unique_ptr<base::StringValue>(new base::StringValue(value));
 }
 
-std::unique_ptr<base::DictionaryValue> TypedValueToJson(
-    const ValueMap& value,
-    chromeos::ErrorPtr* error) {
+std::unique_ptr<base::DictionaryValue> TypedValueToJson(const ValueMap& value) {
   std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
   for (const auto& pair : value) {
-    auto prop_value = pair.second->ToJson(error);
-    if (!prop_value)
-      return nullptr;
+    auto prop_value = pair.second->ToJson();
+    CHECK(prop_value);
     dict->SetWithoutPathExpansion(pair.first, prop_value.release());
   }
   return dict;
 }
 
-std::unique_ptr<base::ListValue> TypedValueToJson(const ValueVector& value,
-                                                  chromeos::ErrorPtr* error) {
+std::unique_ptr<base::ListValue> TypedValueToJson(const ValueVector& value) {
   std::unique_ptr<base::ListValue> list(new base::ListValue);
   for (const auto& item : value) {
-    auto json = item->ToJson(error);
-    if (!json)
-      return nullptr;
+    auto json = item->ToJson();
+    CHECK(json);
     list->Append(json.release());
   }
   return list;
@@ -264,14 +252,14 @@
 }
 
 std::string ToString(const ValueMap& obj) {
-  auto val = TypedValueToJson(obj, nullptr);
+  auto val = TypedValueToJson(obj);
   std::string str;
   base::JSONWriter::Write(*val, &str);
   return str;
 }
 
 std::string ToString(const ValueVector& arr) {
-  auto val = TypedValueToJson(arr, nullptr);
+  auto val = TypedValueToJson(arr);
   std::string str;
   base::JSONWriter::Write(*val, &str);
   return str;
diff --git a/libweave/src/commands/schema_utils.h b/libweave/src/commands/schema_utils.h
index 6d1b342..ea1639f 100644
--- a/libweave/src/commands/schema_utils.h
+++ b/libweave/src/commands/schema_utils.h
@@ -54,30 +54,19 @@
 // A bunch of helper function to create base::Value for specific C++ classes,
 // including vectors of types. These are used in template classes below
 // to simplify specialization logic.
-std::unique_ptr<base::FundamentalValue> TypedValueToJson(
-    bool value,
-    chromeos::ErrorPtr* error);
-std::unique_ptr<base::FundamentalValue> TypedValueToJson(
-    int value,
-    chromeos::ErrorPtr* error);
-std::unique_ptr<base::FundamentalValue> TypedValueToJson(
-    double value,
-    chromeos::ErrorPtr* error);
-std::unique_ptr<base::StringValue> TypedValueToJson(const std::string& value,
-                                                    chromeos::ErrorPtr* error);
-std::unique_ptr<base::DictionaryValue> TypedValueToJson(
-    const ValueMap& value,
-    chromeos::ErrorPtr* error);
-std::unique_ptr<base::ListValue> TypedValueToJson(const ValueVector& value,
-                                                  chromeos::ErrorPtr* error);
+std::unique_ptr<base::FundamentalValue> TypedValueToJson(bool value);
+std::unique_ptr<base::FundamentalValue> TypedValueToJson(int value);
+std::unique_ptr<base::FundamentalValue> TypedValueToJson(double value);
+std::unique_ptr<base::StringValue> TypedValueToJson(const std::string& value);
+std::unique_ptr<base::DictionaryValue> TypedValueToJson(const ValueMap& value);
+std::unique_ptr<base::ListValue> TypedValueToJson(const ValueVector& value);
 template <typename T>
-std::unique_ptr<base::ListValue> TypedValueToJson(const std::vector<T>& values,
-                                                  chromeos::ErrorPtr* error) {
+std::unique_ptr<base::ListValue> TypedValueToJson(
+    const std::vector<T>& values) {
   std::unique_ptr<base::ListValue> list(new base::ListValue);
   for (const auto& v : values) {
-    auto json = TypedValueToJson(v, error);
-    if (!json)
-      return nullptr;
+    auto json = TypedValueToJson(v);
+    CHECK(json);
     list->Append(json.release());
   }
   return list;
diff --git a/libweave/src/commands/schema_utils_unittest.cc b/libweave/src/commands/schema_utils_unittest.cc
index b3181df..6924d3b 100644
--- a/libweave/src/commands/schema_utils_unittest.cc
+++ b/libweave/src/commands/schema_utils_unittest.cc
@@ -25,29 +25,29 @@
 using chromeos::VariantDictionary;
 
 TEST(CommandSchemaUtils, TypedValueToJson_Scalar) {
-  EXPECT_JSON_EQ("true", *TypedValueToJson(true, nullptr));
-  EXPECT_JSON_EQ("false", *TypedValueToJson(false, nullptr));
+  EXPECT_JSON_EQ("true", *TypedValueToJson(true));
+  EXPECT_JSON_EQ("false", *TypedValueToJson(false));
 
-  EXPECT_JSON_EQ("0", *TypedValueToJson(0, nullptr));
-  EXPECT_JSON_EQ("-10", *TypedValueToJson(-10, nullptr));
-  EXPECT_JSON_EQ("20", *TypedValueToJson(20, nullptr));
+  EXPECT_JSON_EQ("0", *TypedValueToJson(0));
+  EXPECT_JSON_EQ("-10", *TypedValueToJson(-10));
+  EXPECT_JSON_EQ("20", *TypedValueToJson(20));
 
-  EXPECT_JSON_EQ("0.0", *TypedValueToJson(0.0, nullptr));
-  EXPECT_JSON_EQ("1.2", *TypedValueToJson(1.2, nullptr));
+  EXPECT_JSON_EQ("0.0", *TypedValueToJson(0.0));
+  EXPECT_JSON_EQ("1.2", *TypedValueToJson(1.2));
 
-  EXPECT_JSON_EQ("'abc'", *TypedValueToJson(std::string("abc"), nullptr));
+  EXPECT_JSON_EQ("'abc'", *TypedValueToJson(std::string("abc")));
 
   std::vector<bool> bool_array{true, false};
-  EXPECT_JSON_EQ("[true,false]", *TypedValueToJson(bool_array, nullptr));
+  EXPECT_JSON_EQ("[true,false]", *TypedValueToJson(bool_array));
 
   std::vector<int> int_array{1, 2, 5};
-  EXPECT_JSON_EQ("[1,2,5]", *TypedValueToJson(int_array, nullptr));
+  EXPECT_JSON_EQ("[1,2,5]", *TypedValueToJson(int_array));
 
   std::vector<double> dbl_array{1.1, 2.2};
-  EXPECT_JSON_EQ("[1.1,2.2]", *TypedValueToJson(dbl_array, nullptr));
+  EXPECT_JSON_EQ("[1.1,2.2]", *TypedValueToJson(dbl_array));
 
   std::vector<std::string> str_array{"a", "bc"};
-  EXPECT_JSON_EQ("['a','bc']", *TypedValueToJson(str_array, nullptr));
+  EXPECT_JSON_EQ("['a','bc']", *TypedValueToJson(str_array));
 }
 
 TEST(CommandSchemaUtils, TypedValueToJson_Object) {
@@ -56,8 +56,7 @@
 
   object.insert(std::make_pair("width", int_type.CreateValue(640, nullptr)));
   object.insert(std::make_pair("height", int_type.CreateValue(480, nullptr)));
-  EXPECT_JSON_EQ("{'height':480,'width':640}",
-                 *TypedValueToJson(object, nullptr));
+  EXPECT_JSON_EQ("{'height':480,'width':640}", *TypedValueToJson(object));
 }
 
 TEST(CommandSchemaUtils, TypedValueToJson_Array) {
@@ -66,7 +65,7 @@
 
   arr.push_back(int_type.CreateValue(640, nullptr));
   arr.push_back(int_type.CreateValue(480, nullptr));
-  EXPECT_JSON_EQ("[640,480]", *TypedValueToJson(arr, nullptr));
+  EXPECT_JSON_EQ("[640,480]", *TypedValueToJson(arr));
 }
 
 TEST(CommandSchemaUtils, TypedValueFromJson_Bool) {
diff --git a/libweave/src/device_registration_info.cc b/libweave/src/device_registration_info.cc
index e733d1b..e6d90bb 100644
--- a/libweave/src/device_registration_info.cc
+++ b/libweave/src/device_registration_info.cc
@@ -398,9 +398,8 @@
     return nullptr;
 
   std::unique_ptr<base::DictionaryValue> state =
-      state_manager_->GetStateValuesAsJson(error);
-  if (!state)
-    return nullptr;
+      state_manager_->GetStateValuesAsJson();
+  CHECK(state);
 
   std::unique_ptr<base::DictionaryValue> resource{new base::DictionaryValue};
   if (!config_->device_id().empty())
@@ -1040,10 +1039,8 @@
 
     std::unique_ptr<base::DictionaryValue> changes{new base::DictionaryValue};
     for (const auto& pair : state_change.changed_properties) {
-      auto value = pair.second->ToJson(nullptr);
-      if (!value) {
-        return;
-      }
+      auto value = pair.second->ToJson();
+      CHECK(value);
       // The key in |pair.first| is the full property name in format
       // "package.property_name", so must use DictionaryValue::Set() instead of
       // DictionaryValue::SetWithoutPathExpansion to recreate the JSON
diff --git a/libweave/src/privet/cloud_delegate.cc b/libweave/src/privet/cloud_delegate.cc
index 33d8a25..80bb052 100644
--- a/libweave/src/privet/cloud_delegate.cc
+++ b/libweave/src/privet/cloud_delegate.cc
@@ -266,7 +266,7 @@
 
   void OnStateChanged() {
     state_.Clear();
-    auto state = state_manager_->GetStateValuesAsJson(nullptr);
+    auto state = state_manager_->GetStateValuesAsJson();
     CHECK(state);
     state_.MergeDictionary(state.get());
     NotifyOnStateChanged();
diff --git a/libweave/src/states/state_manager.cc b/libweave/src/states/state_manager.cc
index 158d79c..850541d 100644
--- a/libweave/src/states/state_manager.cc
+++ b/libweave/src/states/state_manager.cc
@@ -97,15 +97,12 @@
     cb.Run();
 }
 
-std::unique_ptr<base::DictionaryValue> StateManager::GetStateValuesAsJson(
-    chromeos::ErrorPtr* error) const {
+std::unique_ptr<base::DictionaryValue> StateManager::GetStateValuesAsJson()
+    const {
   std::unique_ptr<base::DictionaryValue> dict{new base::DictionaryValue};
   for (const auto& pair : packages_) {
-    auto pkg_value = pair.second->GetValuesAsJson(error);
-    if (!pkg_value) {
-      dict.reset();
-      break;
-    }
+    auto pkg_value = pair.second->GetValuesAsJson();
+    CHECK(pkg_value);
     dict->SetWithoutPathExpansion(pair.first, pkg_value.release());
   }
   return dict;
diff --git a/libweave/src/states/state_manager.h b/libweave/src/states/state_manager.h
index 99f561d..8b22c2f 100644
--- a/libweave/src/states/state_manager.h
+++ b/libweave/src/states/state_manager.h
@@ -41,8 +41,7 @@
   void AddOnChangedCallback(const base::Closure& callback) override;
   bool SetProperties(const chromeos::VariantDictionary& property_set,
                      chromeos::ErrorPtr* error) override;
-  std::unique_ptr<base::DictionaryValue> GetStateValuesAsJson(
-      chromeos::ErrorPtr* error) const override;
+  std::unique_ptr<base::DictionaryValue> GetStateValuesAsJson() const override;
 
   // Initializes the state manager and load device state fragments.
   // Called by Buffet daemon at startup.
diff --git a/libweave/src/states/state_manager_unittest.cc b/libweave/src/states/state_manager_unittest.cc
index 60eafcd..15030eb 100644
--- a/libweave/src/states/state_manager_unittest.cc
+++ b/libweave/src/states/state_manager_unittest.cc
@@ -103,7 +103,7 @@
       'target': ''
     }
   })";
-  EXPECT_JSON_EQ(expected, *mgr_->GetStateValuesAsJson(nullptr));
+  EXPECT_JSON_EQ(expected, *mgr_->GetStateValuesAsJson());
 }
 
 TEST_F(StateManagerTest, LoadStateDefinition) {
@@ -128,7 +128,7 @@
       'target': ''
     }
   })";
-  EXPECT_JSON_EQ(expected, *mgr_->GetStateValuesAsJson(nullptr));
+  EXPECT_JSON_EQ(expected, *mgr_->GetStateValuesAsJson());
 }
 
 TEST_F(StateManagerTest, SetPropertyValue) {
@@ -149,7 +149,7 @@
       'target': 'John Connor'
     }
   })";
-  EXPECT_JSON_EQ(expected, *mgr_->GetStateValuesAsJson(nullptr));
+  EXPECT_JSON_EQ(expected, *mgr_->GetStateValuesAsJson());
 }
 
 TEST_F(StateManagerTest, SetPropertyValue_Error_NoName) {
@@ -224,7 +224,7 @@
       'target': ''
     }
   })";
-  EXPECT_JSON_EQ(expected, *mgr_->GetStateValuesAsJson(nullptr));
+  EXPECT_JSON_EQ(expected, *mgr_->GetStateValuesAsJson());
 }
 
 }  // namespace weave
diff --git a/libweave/src/states/state_package.cc b/libweave/src/states/state_package.cc
index 98f5b9a..b34fc39 100644
--- a/libweave/src/states/state_package.cc
+++ b/libweave/src/states/state_package.cc
@@ -66,15 +66,11 @@
   return true;
 }
 
-std::unique_ptr<base::DictionaryValue> StatePackage::GetValuesAsJson(
-    chromeos::ErrorPtr* error) const {
+std::unique_ptr<base::DictionaryValue> StatePackage::GetValuesAsJson() const {
   std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
   for (const auto& pair : values_) {
-    auto value = pair.second->ToJson(error);
-    if (!value) {
-      dict.reset();
-      break;
-    }
+    auto value = pair.second->ToJson();
+    CHECK(value);
     dict->SetWithoutPathExpansion(pair.first, value.release());
   }
   return dict;
diff --git a/libweave/src/states/state_package.h b/libweave/src/states/state_package.h
index e4e9942..1fceb2e 100644
--- a/libweave/src/states/state_package.h
+++ b/libweave/src/states/state_package.h
@@ -52,8 +52,7 @@
   //      "message": "Printer low on cyan ink"
   //    }
   //  }
-  std::unique_ptr<base::DictionaryValue> GetValuesAsJson(
-      chromeos::ErrorPtr* error) const;
+  std::unique_ptr<base::DictionaryValue> GetValuesAsJson() const;
 
   // Gets the value for a specific state property. |property_name| must not
   // include the package name as part of the property name.
diff --git a/libweave/src/states/state_package_unittest.cc b/libweave/src/states/state_package_unittest.cc
index 6d14731..74075fa 100644
--- a/libweave/src/states/state_package_unittest.cc
+++ b/libweave/src/states/state_package_unittest.cc
@@ -109,7 +109,7 @@
       'type': 'boolean'
     }
   })";
-  EXPECT_JSON_EQ(expected, *GetTypes(package).ToJson(true, false, nullptr));
+  EXPECT_JSON_EQ(expected, *GetTypes(package).ToJson(true, false));
 
   expected = R"({
     'color': '',
@@ -117,7 +117,7 @@
     'iso': 0,
     'light': false
   })";
-  EXPECT_JSON_EQ(expected, *package.GetValuesAsJson(nullptr));
+  EXPECT_JSON_EQ(expected, *package.GetValuesAsJson());
 }
 
 TEST(StatePackage, AddValuesFromJson_OnEmpty) {
@@ -134,7 +134,7 @@
     'iso': 200,
     'light': true
   })";
-  EXPECT_JSON_EQ(expected, *package.GetValuesAsJson(nullptr));
+  EXPECT_JSON_EQ(expected, *package.GetValuesAsJson());
 }
 
 TEST_F(StatePackageTest, AddSchemaFromJson_AddMore) {
@@ -171,7 +171,7 @@
       'type': 'boolean'
     }
   })";
-  EXPECT_JSON_EQ(expected, *GetTypes(*package_).ToJson(true, false, nullptr));
+  EXPECT_JSON_EQ(expected, *GetTypes(*package_).ToJson(true, false));
 
   expected = R"({
     'brightness': '',
@@ -183,7 +183,7 @@
     'iso': 200,
     'light': true
   })";
-  EXPECT_JSON_EQ(expected, *package_->GetValuesAsJson(nullptr));
+  EXPECT_JSON_EQ(expected, *package_->GetValuesAsJson());
 }
 
 TEST_F(StatePackageTest, AddValuesFromJson_AddMore) {
@@ -202,7 +202,7 @@
     'iso': 200,
     'light': true
   })";
-  EXPECT_JSON_EQ(expected, *package_->GetValuesAsJson(nullptr));
+  EXPECT_JSON_EQ(expected, *package_->GetValuesAsJson());
 }
 
 TEST_F(StatePackageTest, AddSchemaFromJson_Error_Redefined) {
@@ -281,7 +281,7 @@
     'iso': 200,
     'light': true
   })";
-  EXPECT_JSON_EQ(expected, *package_->GetValuesAsJson(nullptr));
+  EXPECT_JSON_EQ(expected, *package_->GetValuesAsJson());
 }
 
 TEST_F(StatePackageTest, SetPropertyValue_Error_TypeMismatch) {