Skip to content

Commit

Permalink
Merge pull request #273 from dayjaby/error-missing-return-value
Browse files Browse the repository at this point in the history
protoc_gen_mavsdk: error on missing return value
  • Loading branch information
JonasVautherin authored Jan 29, 2022
2 parents 5cb33bb + 4bc0d91 commit 6b5a443
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion pb_plugins/protoc_gen_mavsdk/methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,18 @@ def extract_return_type_and_name(self, pb_method, responses):
if len(return_params) > 1:
raise Exception(
"Responses cannot have more than 1 return parameter" +
f"(and an optional '*Result')!\nError in {method_output}")
f" (and an optional '*Result')!\nError in {method_output}")

if len(return_params) == 1:
self._return_type = type_info_factory.create(
return_params[0]['field'])
self._return_name = name_parser_factory.create(
return_params[0]['field'].json_name)
self._return_description = return_params[0]['docs']
elif len(return_params) == 0 and self.return_type_required:
raise Exception(
"This response must have 1 return parameter" +
f" (and an optional '*Result')!\nError in {method_output}")

def extract_async_type(self, pb_method):
self._is_sync = True
Expand Down Expand Up @@ -119,6 +123,10 @@ def package(self):
def name(self):
return self._name

@property
def return_type_required(self):
return False

@staticmethod
def collect_methods(
plugin_name,
Expand Down Expand Up @@ -270,6 +278,10 @@ def __init__(
remove_subscribe(pb_method.name))
self._template = template_env.get_template("stream.j2")

@property
def return_type_required(self):
return True

def __repr__(self):
return self._template.render(
name=self._name,
Expand Down

0 comments on commit 6b5a443

Please sign in to comment.