Skip to content

[REQ] php-laravel generator should leave exception handling to the framework #21109

Open
@holkerveen

Description

@holkerveen

Is your feature request related to a problem? Please describe.

IMHO the exception handling used in the api_controller.mustache should be modified a bit. Right now the operation call is wrapped in a try/catch statement but that approach has a few problems:

  • No control over the error message which might be a security concern if the message contains sensitive information
  • There is no way to override the default behaviour, so all you would get as a response is the exception message. I would like to be able to add debug information such as a stack trace when in a development environment
  • The error is not logged anywhere

Describe the solution you'd like

The best option would be to completely omit the try/catch around the operation call. That would leave the exception handling to the Laravel framework, which provides consistent error handling across the application. Developers can then extend and modify the exception handling as they see fit.

Describe alternatives you've considered

This can easily be accomplished with a template override. However, I think the proposed solution is a much better default.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions