Skip to content

Commit

Permalink
Return NcMethodResultError on error, not NcMethodResult
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-r-thorpe committed Nov 1, 2024
1 parent 5bc8b7c commit 9fd51b4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
10 changes: 8 additions & 2 deletions Development/nmos/control_protocol_methods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,20 @@ namespace nmos
{
if (nmos::fields::nc::is_read_only(property))
{
return details::make_nc_method_result({ nc_method_status::read_only });
utility::stringstream_t ss;
ss << U("can not set read only property: ") << property_id.serialize();
slog::log<slog::severities::error>(gate, SLOG_FLF) << ss.str();

Check warning on line 56 in Development/nmos/control_protocol_methods.cpp

View workflow job for this annotation

GitHub Actions / windows-2022: build and test (install mdns: false, use conan: true, force cpprest asio: true, dns-sd mode: multicast, enable_authorization: false)

nonstandard extension used: 'argument': conversion from 'slog::detail::`anonymous-namespace'::log<slog::base_gate,20>' to 'slog::log_statement &'

Check warning on line 56 in Development/nmos/control_protocol_methods.cpp

View workflow job for this annotation

GitHub Actions / windows-2022: build and test (install mdns: false, use conan: true, force cpprest asio: true, dns-sd mode: multicast, enable_authorization: false)

nonstandard extension used: 'argument': conversion from 'slog::detail::`anonymous-namespace'::log<slog::base_gate,20>' to 'slog::log_statement &'

Check warning on line 56 in Development/nmos/control_protocol_methods.cpp

View workflow job for this annotation

GitHub Actions / windows-2019: build and test (install mdns: false, use conan: true, force cpprest asio: false, dns-sd mode: multicast, enable_authorization: true)

nonstandard extension used: 'argument': conversion from 'slog::detail::`anonymous-namespace'::log<slog::base_gate,20>' to 'slog::log_statement &'

Check warning on line 56 in Development/nmos/control_protocol_methods.cpp

View workflow job for this annotation

GitHub Actions / windows-2019: build and test (install mdns: false, use conan: true, force cpprest asio: false, dns-sd mode: multicast, enable_authorization: true)

nonstandard extension used: 'argument': conversion from 'slog::detail::`anonymous-namespace'::log<slog::base_gate,20>' to 'slog::log_statement &'

Check warning on line 56 in Development/nmos/control_protocol_methods.cpp

View workflow job for this annotation

GitHub Actions / windows-2022: build and test (install mdns: false, use conan: true, force cpprest asio: true, dns-sd mode: multicast, enable_authorization: true)

nonstandard extension used: 'argument': conversion from 'slog::detail::`anonymous-namespace'::log<slog::base_gate,20>' to 'slog::log_statement &'

Check warning on line 56 in Development/nmos/control_protocol_methods.cpp

View workflow job for this annotation

GitHub Actions / windows-2022: build and test (install mdns: false, use conan: true, force cpprest asio: true, dns-sd mode: multicast, enable_authorization: true)

nonstandard extension used: 'argument': conversion from 'slog::detail::`anonymous-namespace'::log<slog::base_gate,20>' to 'slog::log_statement &'
return details::make_nc_method_result_error({ nc_method_status::read_only }, ss.str());
}

if ((val.is_null() && !nmos::fields::nc::is_nullable(property))
|| (!val.is_array() && nmos::fields::nc::is_sequence(property))
|| (val.is_array() && !nmos::fields::nc::is_sequence(property)))
{
return details::make_nc_method_result({ nc_method_status::parameter_error });
utility::stringstream_t ss;
ss << U("parameter error: can not set value: ") << val.serialize() << U(" on property: ") << property_id.serialize();
slog::log<slog::severities::error>(gate, SLOG_FLF) << ss.str();

Check warning on line 66 in Development/nmos/control_protocol_methods.cpp

View workflow job for this annotation

GitHub Actions / windows-2022: build and test (install mdns: false, use conan: true, force cpprest asio: true, dns-sd mode: multicast, enable_authorization: false)

nonstandard extension used: 'argument': conversion from 'slog::detail::`anonymous-namespace'::log<slog::base_gate,20>' to 'slog::log_statement &'

Check warning on line 66 in Development/nmos/control_protocol_methods.cpp

View workflow job for this annotation

GitHub Actions / windows-2022: build and test (install mdns: false, use conan: true, force cpprest asio: true, dns-sd mode: multicast, enable_authorization: false)

nonstandard extension used: 'argument': conversion from 'slog::detail::`anonymous-namespace'::log<slog::base_gate,20>' to 'slog::log_statement &'

Check warning on line 66 in Development/nmos/control_protocol_methods.cpp

View workflow job for this annotation

GitHub Actions / windows-2019: build and test (install mdns: false, use conan: true, force cpprest asio: false, dns-sd mode: multicast, enable_authorization: true)

nonstandard extension used: 'argument': conversion from 'slog::detail::`anonymous-namespace'::log<slog::base_gate,20>' to 'slog::log_statement &'

Check warning on line 66 in Development/nmos/control_protocol_methods.cpp

View workflow job for this annotation

GitHub Actions / windows-2019: build and test (install mdns: false, use conan: true, force cpprest asio: false, dns-sd mode: multicast, enable_authorization: true)

nonstandard extension used: 'argument': conversion from 'slog::detail::`anonymous-namespace'::log<slog::base_gate,20>' to 'slog::log_statement &'

Check warning on line 66 in Development/nmos/control_protocol_methods.cpp

View workflow job for this annotation

GitHub Actions / windows-2022: build and test (install mdns: false, use conan: true, force cpprest asio: true, dns-sd mode: multicast, enable_authorization: true)

nonstandard extension used: 'argument': conversion from 'slog::detail::`anonymous-namespace'::log<slog::base_gate,20>' to 'slog::log_statement &'

Check warning on line 66 in Development/nmos/control_protocol_methods.cpp

View workflow job for this annotation

GitHub Actions / windows-2022: build and test (install mdns: false, use conan: true, force cpprest asio: true, dns-sd mode: multicast, enable_authorization: true)

nonstandard extension used: 'argument': conversion from 'slog::detail::`anonymous-namespace'::log<slog::base_gate,20>' to 'slog::log_statement &'
return details::make_nc_method_result_error({ nc_method_status::parameter_error }, ss.str());
}

try
Expand Down
8 changes: 6 additions & 2 deletions Development/nmos/control_protocol_ws_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,10 @@ namespace nmos
catch (const nmos::control_protocol_exception& e)
{
// invalid arguments
slog::log<slog::severities::error>(gate, SLOG_FLF) << "invalid argument: " << arguments.serialize() << " error: " << e.what();
nc_method_result = details::make_nc_method_result({ nmos::nc_method_status::parameter_error });
utility::stringstream_t ss;
ss << "invalid argument: " << arguments.serialize() << " error: " << e.what();
slog::log<slog::severities::error>(gate, SLOG_FLF) << ss.str();
nc_method_result = details::make_nc_method_result_error({ nmos::nc_method_status::parameter_error }, ss.str());
}
}
else
Expand All @@ -287,6 +289,7 @@ namespace nmos
utility::stringstream_t ss;
ss << U("unsupported method_id: ") << nmos::fields::nc::method_id(cmd).serialize()
<< U(" for control class class_id: ") << resource->data.at(nmos::fields::nc::class_id).serialize();
slog::log<slog::severities::error>(gate, SLOG_FLF) << ss.str();
nc_method_result = details::make_nc_method_result_error({ nc_method_status::method_not_implemented }, ss.str());
}
}
Expand All @@ -295,6 +298,7 @@ namespace nmos
// resource not found for the given oid
utility::stringstream_t ss;
ss << U("unknown oid: ") << oid;
slog::log<slog::severities::error>(gate, SLOG_FLF) << ss.str();
nc_method_result = details::make_nc_method_result_error({ nc_method_status::bad_oid }, ss.str());
}
// accumulating up response
Expand Down

0 comments on commit 9fd51b4

Please sign in to comment.