Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14033122
D11448.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D11448.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -1290,6 +1290,7 @@
'PhabricatorApplicationTransactionTransactionPHIDType' => 'applications/transactions/phid/PhabricatorApplicationTransactionTransactionPHIDType.php',
'PhabricatorApplicationTransactionValidationError' => 'applications/transactions/error/PhabricatorApplicationTransactionValidationError.php',
'PhabricatorApplicationTransactionValidationException' => 'applications/transactions/exception/PhabricatorApplicationTransactionValidationException.php',
+ 'PhabricatorApplicationTransactionValidationResponse' => 'applications/transactions/response/PhabricatorApplicationTransactionValidationResponse.php',
'PhabricatorApplicationTransactionValueController' => 'applications/transactions/controller/PhabricatorApplicationTransactionValueController.php',
'PhabricatorApplicationTransactionView' => 'applications/transactions/view/PhabricatorApplicationTransactionView.php',
'PhabricatorApplicationUninstallController' => 'applications/meta/controller/PhabricatorApplicationUninstallController.php',
@@ -4476,6 +4477,7 @@
'PhabricatorApplicationTransactionTransactionPHIDType' => 'PhabricatorPHIDType',
'PhabricatorApplicationTransactionValidationError' => 'Phobject',
'PhabricatorApplicationTransactionValidationException' => 'Exception',
+ 'PhabricatorApplicationTransactionValidationResponse' => 'AphrontProxyResponse',
'PhabricatorApplicationTransactionValueController' => 'PhabricatorApplicationTransactionController',
'PhabricatorApplicationTransactionView' => 'AphrontView',
'PhabricatorApplicationUninstallController' => 'PhabricatorApplicationsController',
diff --git a/src/applications/differential/controller/DifferentialCommentSaveController.php b/src/applications/differential/controller/DifferentialCommentSaveController.php
--- a/src/applications/differential/controller/DifferentialCommentSaveController.php
+++ b/src/applications/differential/controller/DifferentialCommentSaveController.php
@@ -127,8 +127,9 @@
->setCancelURI($revision_uri)
->setException($ex);
} catch (PhabricatorApplicationTransactionValidationException $ex) {
- // TODO: Provide a nice Response for rendering these in a clean way.
- throw $ex;
+ return id(new PhabricatorApplicationTransactionValidationResponse())
+ ->setCancelURI($revision_uri)
+ ->setException($ex);
}
$user = $request->getUser();
diff --git a/src/applications/differential/editor/DifferentialTransactionEditor.php b/src/applications/differential/editor/DifferentialTransactionEditor.php
--- a/src/applications/differential/editor/DifferentialTransactionEditor.php
+++ b/src/applications/differential/editor/DifferentialTransactionEditor.php
@@ -55,7 +55,6 @@
$types = parent::getTransactionTypes();
$types[] = PhabricatorTransactions::TYPE_COMMENT;
- $types[] = PhabricatorTransactions::TYPE_EDGE;
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
$types[] = PhabricatorTransactions::TYPE_EDIT_POLICY;
diff --git a/src/applications/transactions/response/PhabricatorApplicationTransactionValidationResponse.php b/src/applications/transactions/response/PhabricatorApplicationTransactionValidationResponse.php
new file mode 100644
--- /dev/null
+++ b/src/applications/transactions/response/PhabricatorApplicationTransactionValidationResponse.php
@@ -0,0 +1,49 @@
+<?php
+
+final class PhabricatorApplicationTransactionValidationResponse
+ extends AphrontProxyResponse {
+
+ private $viewer;
+ private $exception;
+ private $cancelURI;
+
+ public function setCancelURI($cancel_uri) {
+ $this->cancelURI = $cancel_uri;
+ return $this;
+ }
+
+ public function setException(
+ PhabricatorApplicationTransactionValidationException $exception) {
+ $this->exception = $exception;
+ return $this;
+ }
+
+ protected function buildProxy() {
+ return new AphrontDialogResponse();
+ }
+
+ public function reduceProxyResponse() {
+ $request = $this->getRequest();
+
+ $ex = $this->exception;
+ $title = pht('Validation Errors');
+
+ $dialog = id(new AphrontDialogView())
+ ->setUser($request->getUser())
+ ->setTitle($title);
+
+ $list = array();
+ foreach ($ex->getErrors() as $error) {
+ $list[] = phutil_tag(
+ 'li',
+ array(),
+ $error->getMessage());
+ }
+
+ $dialog->appendChild(phutil_tag('ul', array(), $list));
+ $dialog->addCancelButton($this->cancelURI);
+
+ return $this->getProxy()->setDialog($dialog);
+ }
+
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 10, 4:48 PM (2 d, 10 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6732390
Default Alt Text
D11448.diff (4 KB)
Attached To
Mode
D11448: Differential - return a better response for validation error cases
Attached
Detach File
Event Timeline
Log In to Comment