@@ -639,7 +639,7 @@ tl::expected<nlohmann::json, DataProviderErrorInfo> OpcuaPlugin::list_data(const
639639 items.push_back (std::move (item));
640640 }
641641
642- return nlohmann::json{{ " items" , items}};
642+ return tl::expected< nlohmann::json, DataProviderErrorInfo>{nlohmann::json{{ " items" , items} }};
643643}
644644
645645tl::expected<nlohmann::json, DataProviderErrorInfo> OpcuaPlugin::read_data (const std::string & entity_id,
@@ -681,7 +681,7 @@ tl::expected<nlohmann::json, DataProviderErrorInfo> OpcuaPlugin::read_data(const
681681 auto ts = std::chrono::system_clock::to_time_t (snap.timestamp );
682682 result[" timestamp" ] = ts;
683683
684- return result;
684+ return tl::expected<nlohmann::json, DataProviderErrorInfo>{ result} ;
685685}
686686
687687tl::expected<nlohmann::json, DataProviderErrorInfo> OpcuaPlugin::write_data (const std::string & entity_id,
@@ -754,7 +754,7 @@ tl::expected<nlohmann::json, DataProviderErrorInfo> OpcuaPlugin::write_data(cons
754754 result[" value_written" ] = v;
755755 },
756756 write_val);
757- return result;
757+ return tl::expected<nlohmann::json, DataProviderErrorInfo>{ result} ;
758758}
759759
760760// -- OperationProvider interface --
@@ -775,7 +775,7 @@ tl::expected<nlohmann::json, OperationProviderErrorInfo> OpcuaPlugin::list_opera
775775 item[" asynchronous_execution" ] = false ;
776776 items.push_back (std::move (item));
777777 }
778- return nlohmann::json{{ " items" , items}};
778+ return tl::expected< nlohmann::json, OperationProviderErrorInfo>{nlohmann::json{{ " items" , items} }};
779779 }
780780
781781 return tl::make_unexpected (
@@ -860,7 +860,7 @@ OpcuaPlugin::execute_operation(const std::string & entity_id, const std::string
860860 result[" value_written" ] = v;
861861 },
862862 write_val);
863- return result;
863+ return tl::expected<nlohmann::json, OperationProviderErrorInfo>{ result} ;
864864}
865865
866866// -- FaultProvider interface --
@@ -872,7 +872,7 @@ tl::expected<nlohmann::json, FaultProviderErrorInfo> OpcuaPlugin::list_faults(co
872872
873873 auto faults = ctx_->list_entity_faults (entity_id);
874874 if (faults.is_null () || faults.empty ()) {
875- return nlohmann::json{{ " items" , nlohmann::json::array ()}};
875+ return tl::expected< nlohmann::json, FaultProviderErrorInfo>{nlohmann::json{{ " items" , nlohmann::json::array ()} }};
876876 }
877877
878878 if (faults.contains (" faults" ) && faults[" faults" ].is_array ()) {
@@ -886,10 +886,10 @@ tl::expected<nlohmann::json, FaultProviderErrorInfo> OpcuaPlugin::list_faults(co
886886 item[" source_id" ] = f.value (" source_id" , " " );
887887 items.push_back (std::move (item));
888888 }
889- return nlohmann::json{{ " items" , items}};
889+ return tl::expected< nlohmann::json, FaultProviderErrorInfo>{nlohmann::json{{ " items" , items} }};
890890 }
891891
892- return nlohmann::json{{ " items" , nlohmann::json::array ()}};
892+ return tl::expected< nlohmann::json, FaultProviderErrorInfo>{nlohmann::json{{ " items" , nlohmann::json::array ()} }};
893893}
894894
895895tl::expected<nlohmann::json, FaultProviderErrorInfo> OpcuaPlugin::get_fault (const std::string & entity_id,
@@ -902,7 +902,7 @@ tl::expected<nlohmann::json, FaultProviderErrorInfo> OpcuaPlugin::get_fault(cons
902902 if (faults.contains (" faults" ) && faults[" faults" ].is_array ()) {
903903 for (const auto & f : faults[" faults" ]) {
904904 if (f.value (" fault_code" , " " ) == fault_code) {
905- return f ;
905+ return tl::expected<nlohmann::json, FaultProviderErrorInfo>{f} ;
906906 }
907907 }
908908 }
@@ -918,7 +918,8 @@ tl::expected<nlohmann::json, FaultProviderErrorInfo> OpcuaPlugin::clear_fault(co
918918 }
919919
920920 send_clear_fault (fault_code);
921- return nlohmann::json{{" status" , " cleared" }, {" fault_code" , fault_code}, {" entity_id" , entity_id}};
921+ return tl::expected<nlohmann::json, FaultProviderErrorInfo>{
922+ nlohmann::json{{" status" , " cleared" }, {" fault_code" , fault_code}, {" entity_id" , entity_id}}};
922923}
923924
924925} // namespace ros2_medkit_gateway
0 commit comments