Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Catch OpenSSL error.
James Cole82538ba4fccd
diff --git a/app/Import/Prerequisites/BunqPrerequisites.php b/app/Import/Prerequisites/BunqPrerequisites.phpindex 80b8bba85a..82c3918eeb 100644--- a/app/Import/Prerequisites/BunqPrerequisites.php+++ b/app/Import/Prerequisites/BunqPrerequisites.php@@ -26,6 +26,7 @@ use bunq\Context\ApiContext;use bunq\Exception\BadRequestException;use bunq\Exception\BunqException;use bunq\Util\BunqEnumApiEnvironmentType;+use Exception;use FireflyIII\Services\IP\IPRetrievalInterface;use FireflyIII\User;use Illuminate\Support\MessageBag;@@ -122,9 +123,16 @@ class BunqPrerequisites implements PrerequisitesInterface$deviceDescription,$permittedIps);- } catch (BadRequestException $e) {+ } catch (BadRequestException|BunqException|Exception $e) {+ Log::error($e->getMessage());+ Log::error($e->getTraceAsString());+ $message = $e->getMessage();+ if (stripos($message, 'Generating a new private key failed')) {+ $message = 'Could not generate key-material. Please make sure OpenSSL is installed and configured: http://bit.ly/FF3-openSSL';++ }$messages = new MessageBag();- $messages->add('bunq_error', $e->getMessage());+ $messages->add('bunq_error', $message);return $messages;}diff --git a/app/Support/Import/Routine/Bunq/StageImportDataHandler.php b/app/Support/Import/Routine/Bunq/StageImportDataHandler.phpindex a913e63c5c..15a8f8b1f8 100644--- a/app/Support/Import/Routine/Bunq/StageImportDataHandler.php+++ b/app/Support/Import/Routine/Bunq/StageImportDataHandler.php@@ -25,9 +25,12 @@ namespace FireflyIII\Support\Import\Routine\Bunq;use bunq\Context\ApiContext;use bunq\Context\BunqContext;+use bunq\Exception\BadRequestException;+use bunq\Exception\BunqException;use bunq\Model\Generated\Endpoint\Payment;use bunq\Model\Generated\Object\LabelMonetaryAccount;use Carbon\Carbon;+use Exception;use FireflyIII\Exceptions\FireflyException;use FireflyIII\Factory\AccountFactory;use FireflyIII\Models\Account as LocalAccount;@@ -242,7 +245,18 @@ class StageImportDataHandler$preference = app('preferences')->getForUser($this->importJob->user, 'bunq_api_context', null);if (null !== $preference && '' !== (string)$preference->data) {// restore API context- $apiContext = ApiContext::fromJson($preference->data);+ try {+ $apiContext = ApiContext::fromJson($preference->data);+ } catch (BadRequestException|BunqException|Exception $e) {+ Log::error($e->getMessage());+ Log::error($e->getTraceAsString());+ $message = $e->getMessage();+ if (stripos($message, 'Generating a new private key failed')) {+ $message = 'Could not generate key-material. Please make sure OpenSSL is installed and configured: http://bit.ly/FF3-openSSL';++ }+ throw new FireflyException($message);+ }BunqContext::loadApiContext($apiContext);return;diff --git a/app/Support/Import/Routine/Bunq/StageNewHandler.php b/app/Support/Import/Routine/Bunq/StageNewHandler.phpindex a1df1d1546..e83a8db7e7 100644--- a/app/Support/Import/Routine/Bunq/StageNewHandler.php+++ b/app/Support/Import/Routine/Bunq/StageNewHandler.php@@ -25,14 +25,18 @@ namespace FireflyIII\Support\Import\Routine\Bunq;use bunq\Context\ApiContext;use bunq\Context\BunqContext;+use bunq\Exception\BadRequestException;+use bunq\Exception\BunqException;use bunq\Model\Generated\Endpoint\MonetaryAccount;use bunq\Model\Generated\Endpoint\MonetaryAccountBank;use bunq\Model\Generated\Object\Pointer;+use Exception;use FireflyIII\Exceptions\FireflyException;use FireflyIII\Models\ImportJob;use FireflyIII\Models\Preference;use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;use Log;+/*** Class StageNewHandler*/@@ -52,16 +56,28 @@ class StageNewHandler$preference = app('preferences')->getForUser($this->importJob->user, 'bunq_api_context', null);if (null !== $preference && '' !== (string)$preference->data) {// restore API context- $apiContext = ApiContext::fromJson($preference->data);- BunqContext::loadApiContext($apiContext);+ try {+ $apiContext = ApiContext::fromJson($preference->data);+ BunqContext::loadApiContext($apiContext);+ } catch (BadRequestException|BunqException|Exception $e) {+ Log::error($e->getMessage());+ Log::error($e->getTraceAsString());+ $message = $e->getMessage();+ if (stripos($message, 'Generating a new private key failed')) {+ $message = 'Could not generate key-material. Please make sure OpenSSL is installed and configured: http://bit.ly/FF3-openSSL';++ }+ throw new FireflyException($message);+ }// list bunq accounts:$accounts = $this->listAccounts();// store in job:- $config = $this->repository->getConfiguration($this->importJob);+ $config = $this->repository->getConfiguration($this->importJob);$config['accounts'] = $accounts;$this->repository->setConfiguration($this->importJob, $config);+return;}throw new FireflyException('The bunq API context is unexpectedly empty.');