Use correct exception type when saving segment to DB fails
[MAILPOET-4294]
This commit is contained in:
committed by
Veljko V
parent
1d4ec47b25
commit
c8278dde2a
@@ -41,7 +41,15 @@ class Segments {
|
||||
);
|
||||
}
|
||||
|
||||
$segment = $this->segmentsRepository->createOrUpdate($data['name'], $data['description'] ?? '');
|
||||
try {
|
||||
$segment = $this->segmentsRepository->createOrUpdate($data['name'], $data['description'] ?? '');
|
||||
} catch (\Exception $e) {
|
||||
throw new APIException(
|
||||
sprintf(__('Failed to add subscriber: %s', 'mailpoet'), $e->getMessage()),
|
||||
APIException::FAILED_TO_SAVE_LIST
|
||||
);
|
||||
}
|
||||
|
||||
return $this->buildItem($segment);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user