Bug in handling API error

I have an API method which takes a parameter. It looks like:
http://<ip>/api/method/some_func?some_arg=<>

In case the end user doesn’t provide the some_arg URL parameter. I want to handle it better without her seeing the full traceback.

What I’ve done is:

def some_func(some_arg):
  if not some_arg:
            return frappe.respond_as_web_page("Server Error",
                                          "Invalid Arg.",
                                          success=False,
                                          http_status_code=417)

But it looks like the function doesn’t even enter and frappe throws an ugly full trace-back to the end user. Is there a cleaner approach to handle in production?

Thanks

What error you are getting

Set the default values to args

def some_func(some_arg=None):
    #...

@netchampfaris thanks, will fix it using that for now :slight_smile:

@saurabh6790 TypeError: some_func() takes exactly 1 argument (0 given)