Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include exception cause in error output #16

Merged
merged 4 commits into from
Jul 14, 2022
Merged

Conversation

thekid
Copy link
Member

@thekid thekid commented Jul 14, 2022

Before:

$ xp lambda test Env | tail -1 | json_pp
{
   "errorMessage" : "Test",
   "errorType" : "lang.IllegalArgumentException",
   "stackTrace" : [
      "Env::{closure}(...) (line 132 of AwsRunner.class.php)",
      "xp.lambda.AwsRunner::main(...) (line 389 of class-main.php)",
      "Env::{closure}(...) (line 132 of AwsRunner.class.php)",
      "xp.lambda.AwsRunner::main(...) (line 389 of class-main.php)"
   ]
}

After:

$ xp lambda test Env | tail -1 | json_pp
{
   "errorMessage" : "Test",
   "errorType" : "lang.IllegalArgumentException",
   "stackTrace" : [
      "Exception lang.IllegalArgumentException (Test)",
      "Env::{closure}(...) (line 112 of AwsRunner.class.php)",
      "xp.lambda.AwsRunner::main(...) (line 389 of class-main.php)",
      "Exception lang.IllegalStateException (Cause)",
      "Env::{closure}(...) (line 112 of AwsRunner.class.php)",
      "xp.lambda.AwsRunner::main(...) (line 389 of class-main.php)"
   ]
}

@thekid
Copy link
Member Author

thekid commented Jul 14, 2022

Here's a real life scenario where this is helpful:

image

Without the cause message, we would only be seeing the stack trace, and it wouldn't be as obvious why the request has failed. In this case, this is because the "zlib" extension isn't loaded (see #8)

@thekid thekid added the enhancement New feature or request label Jul 14, 2022
@thekid thekid merged commit 2b4fe22 into main Jul 14, 2022
@thekid thekid deleted the feature/exception-cause branch July 14, 2022 12:34
@thekid
Copy link
Member Author

thekid commented Jul 14, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant