-2

I have installed aws-php-sdk in Laravel and configured it correctly where putitem / getitem working when executing through HTTP/HTTPS in the browser and curl. However, when I try to execute the same script through Laravel queue, I am getting this exceptions when trying to instantiate aws client:

local.ERROR: App\Jobs\processjob::failed(): Argument #1 ($exception) must be of type App\Jobs\Throwable, Error given, called in /var/www/html/myappname/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php on line 260 {"exception":"[object] (TypeError(code: 0): App\Jobs\processjob::failed(): Argument #1 ($exception) must be of type App\Jobs\Throwable, Error given, called in /var/www/html/myappname/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php on line 260 at /var/www/html/myappname/app/Jobs/processjob.php:46)

I am using AWS role permission to access dynamodb. I have tried to debug for hours with no luck. Please help!

Ash
  • 1
  • 1

1 Answers1

0

The issue is very simple, processjob class has a failed method (overriden), and it is asking for Throwable $exception, your issue is that Throwable was not imported like a global class (\Throwable) so the PHP thinks it is a class local to the current namespace (App/Jobs).

So, your code should be like this:

function failed(\Throwable $exception)

or, another solution is:

On top of the file (after the namespace keyword), write this: use \Throwable;.

If this does not fix your problem, let me know and share your processjob class, but this should do it...

matiaslauriti
  • 7,065
  • 4
  • 31
  • 43
  • Adding the failed method helped but now getting a different error: /var/www/html/myapp/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php(159): GuzzleHttp\\Promise\\TaskQueue->run() Like before, going through the browser works but through the processjob fails with the above error. – Ash Apr 22 '23 at 18:19