Better error messaging

This commit is contained in:
David Bomba 2021-05-26 13:17:22 +10:00
parent c4bd6b2338
commit 6cb340ddad
4 changed files with 8 additions and 11 deletions

View File

@ -425,13 +425,9 @@ class Import implements ShouldQueue
'*.first_name' => ['string'], '*.first_name' => ['string'],
'*.last_name' => ['string'], '*.last_name' => ['string'],
//'*.email' => ['distinct'], //'*.email' => ['distinct'],
'*.email' => ['distinct', 'email', new ValidUserForCompany(), new AttachableUser()], '*.email' => ['distinct', 'email', new ValidUserForCompany()],
]; ];
// if (config('ninja.db.multi_db_enabled')) {
// array_push($rules['*.email'], new ValidUserForCompany());
// }
$validator = Validator::make($data, $rules); $validator = Validator::make($data, $rules);
if ($validator->fails()) { if ($validator->fails()) {

View File

@ -144,7 +144,7 @@ class StartMigration implements ShouldQueue
if(Ninja::isHosted()) if(Ninja::isHosted())
app('sentry')->captureException($e); app('sentry')->captureException($e);
Mail::to($this->user->email, $this->user->name())->send(new MigrationFailed($e, $this->company->settings, $e->getMessage())); Mail::to($this->user->email, $this->user->name())->send(new MigrationFailed($e, $this->company, $e->getMessage()));
if (app()->environment() !== 'production') { if (app()->environment() !== 'production') {
info($e->getMessage()); info($e->getMessage());

View File

@ -8,22 +8,23 @@ use Illuminate\Queue\SerializesModels;
class MigrationFailed extends Mailable class MigrationFailed extends Mailable
{ {
// use Queueable, SerializesModels;
public $exception; public $exception;
public $content; public $content;
public $settings; public $settings;
public $company;
/** /**
* Create a new message instance. * Create a new message instance.
* *
* @param $content * @param $content
* @param $exception * @param $exception
*/ */
public function __construct($exception, $settings, $content = null) public function __construct($exception, $company, $content = null)
{ {
$this->exception = $exception; $this->exception = $exception;
$this->content = $content; $this->content = $content;
$this->settings = $settings; $this->settings = $company->settings;
$this->company = $company;
} }
/** /**
@ -34,6 +35,6 @@ class MigrationFailed extends Mailable
public function build() public function build()
{ {
return $this->from(config('mail.from.address'), config('mail.from.name')) return $this->from(config('mail.from.address'), config('mail.from.name'))
->view('email.migration.failed', ['settings' => $this->settings]); ->view('email.migration.failed', ['settings' => $this->settings, 'company' => $this->company]);
} }
} }

View File

@ -3,7 +3,7 @@
@include('email.components.header', ['logo' => 'https://www.invoiceninja.com/wp-content/uploads/2015/10/logo-white-horizontal-1.png']) @include('email.components.header', ['logo' => 'https://www.invoiceninja.com/wp-content/uploads/2015/10/logo-white-horizontal-1.png'])
@endslot @endslot
<h1>Whoops, migration failed.</h1> <h1>Whoops, migration failed for {{ $company->present()->name() }}.</h1>
<p>Looks like your migration failed. Here's the error message:</p> <p>Looks like your migration failed. Here's the error message:</p>
<pre> <pre>