[UI] Display error when submitted form is invalid

This commit is contained in:
Hugo Sales
2020-09-08 00:12:33 +00:00
committed by Hugo Sales
parent 5fc7647c40
commit 4c15271d36
7 changed files with 90 additions and 14 deletions

View File

@@ -28,7 +28,8 @@ use App\Core\Security;
use App\Entity\FileToNote;
use App\Entity\Note;
use App\Util\Common;
use App\Util\Exception\ClientException;
use App\Util\Exceptiion\InvalidFormException;
use App\Util\Exception\NoSuchNoteException;
use Component\Media\Media;
use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
@@ -42,7 +43,7 @@ class Post
{
$note = DB::find('note', ['id' => $reply_to]);
if ($note == null) {
throw new ClientException(_m('No such note'));
throw new NoSuchNoteException();
}
$actor_id = Common::ensureLoggedIn()->getId();
@@ -61,7 +62,7 @@ class Post
if ($form->isValid()) {
self::storeNote($actor_id, $data['content'], $data['attachments'], $is_local = true, $data['reply_to'], null);
} else {
// TODO display errors
throw new InvalidFormException();
}
}