diff --git a/app/Services/Migration/AuthService.php b/app/Services/Migration/AuthService.php index e96341fab0a3..1743aee3ef16 100644 --- a/app/Services/Migration/AuthService.php +++ b/app/Services/Migration/AuthService.php @@ -41,8 +41,16 @@ class AuthService $response = Request::post($this->getUrl(), $this->getHeaders(), $body); if ($response->code == 200) { - $this->isSuccessful = true; - $this->token = $response->body->data[0]->token->token; + + try { + $this->isSuccessful = true; + $this->token = $response->body->data[0]->token->token; + } catch (\Exception $e) { + info($e->getMessage()); + + $this->isSuccessful = false; + $this->errors = [trans('texts.migration_went_wrong')]; + } } if (in_array($response->code, [401, 422, 500])) { diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index a3a1429c40f4..a0a5d763e689 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -3535,6 +3535,7 @@ $LANG = array( 'marked_credit_as_sent' => 'Successfully marked credit as sent', 'email_subject_payment_partial' => 'Email Partial Payment Subject', 'is_approved' => 'Is Approved', + 'migration_went_wrong' => 'Oops, something went wrong! Make sure you did proper setup with V2 of Invoice Ninja, before starting migration.', 'cross_migration_message' => 'Cross account migration is not allowed. Please read more about it here: https://invoiceninja.github.io/cross-site-migration.html' );