mehrancodes / laravel-harbor

a cli tool to Quickly create on-demand preview environment for your app on Laravel Forge.
https://www.laravel-harbor.com
MIT License
75 stars 7 forks source link

Improve Clarity of Forge's ValidationException Error Messages in Veyoze CLI #30

Closed mehrancodes closed 12 months ago

mehrancodes commented 12 months ago

Description

Per issue #24, users of the Veyoze CLI, particularly when executing the 'php veyoze provision' command, are faced with lengthy and ambiguous error messages due to the ValidationException. This issue arises during site creation when the OrCreateNewSite class triggers the createSite function from Forge. In cases of invalid payload data, the system throws a ValidationException. However, the subsequent stack trace doesn't clearly delineate the root cause to the end-user.

Expected Behavior

Users should receive a clear, concise error message detailing what part of their input is invalid when a ValidationException occurs.

Proposed Solution

I propose we refine the Exception Handler for this particular exception. When a ValidationException is caught, we should:

  1. Extract the validation error messages from the exception.
  2. Display these validation messages clearly in the CLI output.
  3. Prevent the propagation of the exception to the default logging stack to avoid long, unclear stack traces. This can be achieved by returning false from the exception handling callback, thereby halting further exception handling.

Steps to Reproduce

  1. Run 'php veyoze provision' with an incorrect data value in the payload. For example, set FORGE_NGINX_TEMPLATE to a random number.
  2. Observe the long, unclear stack-trace output when a ValidationException is thrown.

Additional Context

Clearer error messages will improve user experience by quickly informing users of mistakes in their input, allowing for quicker debugging and fewer frustrations.

mgkimsal commented 12 months ago

I was looking in to what it would take to get more detail from the exceptions. Nice work so far.