зеркало из https://github.com/nextcloud/text.git
fix: catch expected exception in event handler
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Родитель
9cf8f1a547
Коммит
e41c3f39f1
lib/Listeners
|
@ -25,6 +25,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Text\Listeners;
|
||||
|
||||
use OCA\Text\Exception\DocumentHasUnsavedChangesException;
|
||||
use OCA\Text\Service\DocumentService;
|
||||
use OCP\EventDispatcher\Event;
|
||||
use OCP\EventDispatcher\IEventListener;
|
||||
|
@ -49,7 +50,11 @@ class BeforeNodeWrittenListener implements IEventListener {
|
|||
if ($node instanceof File && $node->getMimeType() === 'text/markdown') {
|
||||
if (!$this->documentService->isSaveFromText()) {
|
||||
// Reset document session to avoid manual conflict resolution if there's no unsaved steps
|
||||
$this->documentService->resetDocument($node->getId());
|
||||
try {
|
||||
$this->documentService->resetDocument($node->getId());
|
||||
} catch (DocumentHasUnsavedChangesException) {
|
||||
// Do not throw during event handling in this is expected to happen
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче