Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 312583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:01:46+00:00 2026-05-12T08:01:46+00:00

Suppose I have a controller method like so: @expose() def search(self, title): return dict()

  • 0

Suppose I have a controller method like so:

@expose()
def search(self, title):
    return dict()

Going to http://site/search/ will cause an exception to be thrown: TypeError: search() takes exactly 2 arguments (1 given).

The error is logical, but I’d rather handle it more gracefully. Is using *args or **kwargs the only way to avoid an error that I don’t even seem to be able to catch?

EDIT: I guess I could always use title=None, but too much of that could get ugly…

Anyway, is there a way to catch the exception and/or handle argument mismatches more gracefully?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T08:01:46+00:00Added an answer on May 12, 2026 at 8:01 am

    The exception thrown at you for specifying an “incompatible” controller method signature only happens in debug / development mode.
    You dont need to handle it more gracefully in a production environment, because once you disable development mode, controller methods send an HTTP 500 Error when they lack essential parameters.

    You might want to consider the respective settings in your development.ini:

    # WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT*
    # Debug mode will enable the interactive debugging tool, allowing ANYONE to
    # execute malicious code after an exception is raised.
    set debug = false
    

    I hope this was your question.

    In the case that you still want the controller do its work, even though its lacks important parameters, you must define default values, else the controller cannot do its work properly anyway.
    The question you better ask yourself is: Do you simply want a nicer error message, or do you want the controller to be able to do its task. In the latter case, specifying default parameters is best practise, *args and **kwargs for each method just so the customer doesnt get an error is a very ugly hack in my option.

    If you want to change the display of these errors refer to /controllers/error.py

    Hope this helped,

    Tom

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 212k
  • Answers 212k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer There are software techniques, such as a central license server… May 12, 2026 at 10:25 pm
  • Editorial Team
    Editorial Team added an answer - (IBAction)buttonclick1 ... { //You may also want to consider… May 12, 2026 at 10:25 pm
  • Editorial Team
    Editorial Team added an answer That error is within jQuery - seems unrelated to the… May 12, 2026 at 10:25 pm

Related Questions

I have a question regarding how to get the white- and black-listing feature of
Suppose I have this model: public class ViewModel { [Required] public string UserInput {
There's no strongly typed View() method to return an ActionResult. So, suppose I have
yesterday I just asked following question. How to customize tableView Section View - iPhone

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.