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 7841519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:07:03+00:00 2026-06-02T16:07:03+00:00

Accordingly to this doc page: http://symfony.com/doc/current/cookbook/controller/error_pages.html Symfony uses the TwigBundle to control the display

  • 0

Accordingly to this doc page:

http://symfony.com/doc/current/cookbook/controller/error_pages.html

Symfony uses the TwigBundle to control the display of exceptions. However, i’m not looking to customize the display, as mentioned in the doc, i’m looking to override this. I’m working on a small REST API and i wanted to override the calling of TwigBundle to my bundle, making my own exceptions handling (in terms of REST: map correct HTTP status codes and plain-text body responses).

I couldn’t find anything about this and the reference on the manual is not that good, specially on the kernel part. Maybe someone already did this and can help me out? 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-06-02T16:07:03+00:00Added an answer on June 2, 2026 at 4:07 pm

    You should create a listener that listens on kernel.exception event. In onKernelException method of that listener you can check for your exception e.g

    On exception listener class

      //namespace declarations
      class YourExceptionListener
      {
    
          public function onKernelException(GetResponseForExceptionEvent $event)
          {
            $exception =  $event->getException();
            if ($exception instanceof YourException) {
                //create response, set status code etc.
                $event->setResponse($response); //event will stop propagating here. Will not call other listeners.
            }
          }
      }
    

    The service declaration would be

     //services.yml
     kernel.listener.yourlisener:
      class: FQCN\Of\YourExceptionListener
      tags:
        - { name: kernel.event_listener, event: kernel.exception, method: onKernelException }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to get an access_token according to this documentation http://dev.twitter.com/doc/post/oauth/request_token . I use
according to the reference (http://dev.mysql.com/doc/refman/5.5/en/create-table.html), MySQL 5.5 now supports table and column comments of
According to: http://java.sun.com/docs/books/jls/second_edition/html/typesValues.doc.html 4.5.2 Variables of Reference Type A reference type can hold a
I've followed instructions http://code.google.com/webtoolkit/doc/latest/tutorial/gettingstarted.html in order to create sample GWT program. Now I would
There is HTML page with contents like this. Documentation at MDN says that childNodes
So according to Sun's J2EE documentation ( http://docs.sun.com/app/docs/doc/819-3669/bnani?l=en&a=view ), If a tag attribute is
I am checking this PHP quality control tool: PHP_CodeSniffer In its documentation page Example
According to this doc page , Android 2.3 supports extra large screen sizes (xlarge),
I've been following the tutorial on building a sample GWT Application: http://code.google.com/webtoolkit/doc/latest/tutorial/gettingstarted.html I then
I've been here and accordingly found out that this piece of code here var

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.