Problem/Motivation

Currently the usage of HttpException is wrong.
If we use the raw HttpException we need to provide a status code first and then the message.
If we use one of the subclasses we can use the message only.

The current implementation triggers following errors:

  1. InvalidArgumentException: The HTTP status code "1" is not valid. in Symfony\Component\HttpFoundation\Response->setStatusCode() (Zeile 453 in /var/www/vendor/symfony/http-foundation/Response.php) #0 /var/www/web/core/lib/Drupal/Core/EventSubscriber/FinalExceptionSubscriber.php(131): Symfony\Component\HttpFoundation\Response->setStatusCode(1) #1 [internal function]: Drupal\Core\EventSubscriber\FinalExceptionSubscriber->onException(Object(Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent), 'kernel.exceptio...',
  2. Notice: Object of class Drupal\Core\StringTranslation\TranslatableMarkup could not be converted to int in Symfony\Component\HttpFoundation\Response->setStatusCode() (Zeile 451 in /var/www/vendor/symfony/http-foundation/Response.php) #0

Proposed resolution

I'm in favour of using the subclasses of HttpException as it is more speaking.

Remaining tasks

Reviews needed.

User interface changes

None.

API changes

Different / proper http status codes.

Data model changes

None.

Comments

das-peter created an issue. See original summary.

imclean’s picture

Thanks das-peter. I haven't tested it but the patch looks good to me. It fixes an error and doesn't how the module works.

  • imclean committed 38c3a8e on 8.x-2.x authored by das-peter
    Issue #2981475 by das-peter: Invalid usage of HttpException
    
imclean’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.