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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:47:00+00:00 2026-06-17T04:47:00+00:00

I am wondering how would I simulate a 500 error in Symfony 2. I

  • 0

I am wondering how would I simulate a 500 error in Symfony 2.

I have been reading this post where Raise suggests throwing an exception

throw new sfException(‘Testing the 500 error’);

in Symfony 1.4.

I have been placing this code in my

\store\vendor\symfony\symfony\src\Symfony\Bundle\TwigBundle\Controller\ExceptionController.php

but I get the fatal error

Class ‘Symfony\Bundle\TwigBundle\Controller\sfException’ not found in /home/notroot/www/store/vendor/symfony/symfony/src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php on line 49`

Line 49 refers to the exception code I added.

My question is if throwing an exception is still viable in forcing a 500 error in Symfony 2, and if so where do I put this exception?

If this is no longer viable, how would I be able to test for an error 500?

  • 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-17T04:47:01+00:00Added an answer on June 17, 2026 at 4:47 am

    You can do it like this.

    //in your controller
    $response = new Response();
    $response->setStatusCode(500);
    return $response;
    

    Dont forget to add

    use Symfony\Component\HttpFoundation\Response;
    

    at the top of your file.

    Edit : To force Symfony 500 error, your proposition is fine :

    throw new \Exception('Something went wrong!');
    

    Put it in a controller function.

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

Sidebar

Related Questions

I'm wondering what would be best to do. Right now I have running a
I am just wondering would it be better to do this: if((fd = open(filename,
I'm wondering how you would simulate a :has_many :through using an AR call. Ultimately,
I have an assignment problem at hand and am wondering how suitable it would
I am wondering would this make any real efficieny difference (ie computation time, memory
I have a question: I was wondering if it is possible to simulate the
I was wondering would I still need to use a basic game loop for
I am wondering how would you store a list of categories and sub categories
I am wondering what would happen if I tried to read files in Java
Hey im just wondering what would be the best collection to use when creating

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.