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

  • SEARCH
  • Home
  • 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 6362695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:56:31+00:00 2026-05-24T23:56:31+00:00

Bottle.py ships with an import to handle throwing HTTPErrors and route to a function.

  • 0

Bottle.py ships with an import to handle throwing HTTPErrors and route to a function.

Firstly, the documentation claims I can (and so do several examples):

from bottle import error

@error(500)
def custom500(error):
    return 'my custom message'

however, when importing this statement error is unresolved but on running the application ignores this and just directs me to the generic error page.

I found a way to get around this by:

from bottle import Bottle

main = Bottle()

@Bottle.error(main, 500)
def custom500(error):
    return 'my custom message'

But this code prevents me from embedding my errors all in a separate module to control the nastiness that would ensue if I kept them in my main.py module because the first argument has to be a bottle instance.

So my questions:

  1. Has anyone else experienced this?

  2. why doesn’t error seem to resolve in only my case (I installed from pip install bottle)?

  3. Is there a seamless way to import my error routing from a separate python module into the main application?

  • 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-24T23:56:32+00:00Added an answer on May 24, 2026 at 11:56 pm

    If you want to embed your errors in another module, you could do something like this:

    error.py

    def custom500(error):
        return 'my custom message'
    
    handler = {
        500: custom500,
    }
    

    app.py

    from bottle import *
    import error
    
    app = Bottle()
    app.error_handler = error.handler
    
    @app.route('/')
    def divzero():
        return 1/0
    
    run(app)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

from bottle import route, run, debug, error, request, template @route('/home') @route('/home/') def login(): return
Bottle can use several webservers: Build-in HTTP development server and support for paste, fapws3,
When I run bottle development server, I notice some warning showing up. Can any
Is there any tool can measure execution time for each function call and find
I am making a bottle collection program. I am inputting bottles collects from 4
How do I go about returning json data from a bottle request handler. I
I'm running the micro framework Bottle on Google App Engine. I'm using Jinja2 for
I'm a python newbie and starting out with using the Bottle web framework on
I'm working on writing a small WSGI application using Bottle and SqlAlchemy and am
I would like to embed the great Bottle web framework into a small application

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.