Page MenuHomePhabricator

D14164.id34228.diff
No OneTemporary

D14164.id34228.diff

diff --git a/src/applications/herald/controller/HeraldRuleController.php b/src/applications/herald/controller/HeraldRuleController.php
--- a/src/applications/herald/controller/HeraldRuleController.php
+++ b/src/applications/herald/controller/HeraldRuleController.php
@@ -24,6 +24,8 @@
}
$cancel_uri = $this->getApplicationURI("rule/{$id}/");
} else {
+ $new_uri = $this->getApplicationURI('new/');
+
$rule = new HeraldRule();
$rule->setAuthorPHID($viewer->getPHID());
$rule->setMustMatchAll(1);
@@ -33,18 +35,40 @@
$rule_type = $request->getStr('rule_type');
if (!isset($rule_type_map[$rule_type])) {
- $rule_type = HeraldRuleTypeConfig::RULE_TYPE_PERSONAL;
+ return $this->newDialog()
+ ->setTitle(pht('Invalid Rule Type'))
+ ->appendParagraph(
+ pht(
+ 'The selected rule type ("%s") is not recognized by Herald.',
+ $rule_type))
+ ->addCancelButton($new_uri);
}
$rule->setRuleType($rule_type);
- $adapter = HeraldAdapter::getAdapterForContentType(
- $rule->getContentType());
+ try {
+ $adapter = HeraldAdapter::getAdapterForContentType(
+ $rule->getContentType());
+ } catch (Exception $ex) {
+ return $this->newDialog()
+ ->setTitle(pht('Invalid Content Type'))
+ ->appendParagraph(
+ pht(
+ 'The selected content type ("%s") is not recognized by '.
+ 'Herald.',
+ $rule->getContentType()))
+ ->addCancelButton($new_uri);
+ }
if (!$adapter->supportsRuleType($rule->getRuleType())) {
- throw new Exception(
- pht(
- "This rule's content type does not support the selected rule ".
- "type."));
+ return $this->newDialog()
+ ->setTitle(pht('Rule/Content Mismatch'))
+ ->appendParagraph(
+ pht(
+ 'The selected rule type ("%s") is not supported by the selected '.
+ 'content type ("%s").',
+ $rule->getRuleType(),
+ $rule->getContentType()))
+ ->addCancelButton($new_uri);
}
if ($rule->isObjectRule()) {

File Metadata

Mime Type
text/plain
Expires
Sun, Mar 9, 1:49 AM (2 d, 23 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7385607
Default Alt Text
D14164.id34228.diff (2 KB)

Event Timeline