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

Getting the exception on failure #105

Closed
hasyimibhar opened this issue Nov 23, 2017 · 6 comments
Closed

Getting the exception on failure #105

hasyimibhar opened this issue Nov 23, 2017 · 6 comments

Comments

@hasyimibhar
Copy link

Is there a way to get the exception from the underlying client? Currently the exception is logged and false is returned.

I think it would be better to let the exception pass through and let the caller handle it himself, even though it partially violates the interface of the save method.

@baopham
Copy link
Owner

baopham commented Nov 23, 2017

I prefer to follow the interface. But let's see how we can resolve your issue. What are the particular errors that you are trying to catch?

@zoul0813
Copy link
Contributor

@baopham - a similar issue came up with a Cognito package I’m contributing too, we ended up making it a config option. Default swallowed the exception and returned true/false and another option allowed it to throw the exception, a third option introduced an error handler.

We could maybe look into this as an option for dynamodb?

@baopham
Copy link
Owner

baopham commented Nov 23, 2017

Yep good idea @zoul0813
We can keep it simple:

// dynamodb.php config
return [
   ...,
   // If empty, default to swallow
   // If want to throw, pass in the provided BaoPham\DynamoDb\ErrorHandlers\RaiseError::class
   // If want to handle errors directly, pass in a custom class
   'error_handler' => App\CustomDynamoDbErrorHandler::class
];

The above might mean that the custom error handler won't have much context of which method of which class that causes the error though.

It'd be better if we know more about your use case @hasyimibhar

@hasyimibhar
Copy link
Author

hasyimibhar commented Nov 24, 2017

@baopham I'm saving something to DynamoDb from a queued job. I usually let unexpected exception pass through and halt the job, and I'll get notified (via email, Slack, etc.) of exactly why my job failed.

If there is a way to get the underlying exception when save returns false, that should be good enough for me. A detailed error context not important for my case.

@baopham
Copy link
Owner

baopham commented Nov 24, 2017

ok, after thinking about it, I think we don't have to catch all exception like how it is right now. Thanks for reporting this, will work on it.

@baopham
Copy link
Owner

baopham commented Nov 24, 2017

Done. Please use v3.0.0

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

No branches or pull requests

3 participants