jenkins-bot has submitted this change and it was merged.

Change subject: Properly handle exceptions in flow-parsoid-utils
......................................................................


Properly handle exceptions in flow-parsoid-utils

Change-Id: I646322a03de9e82039d9744617b86716e37319ff
---
M includes/api/ApiParsoidUtilsFlow.php
1 file changed, 10 insertions(+), 1 deletion(-)

Approvals:
  Matthias Mullie: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/api/ApiParsoidUtilsFlow.php 
b/includes/api/ApiParsoidUtilsFlow.php
index b75ac49..27d0865 100644
--- a/includes/api/ApiParsoidUtilsFlow.php
+++ b/includes/api/ApiParsoidUtilsFlow.php
@@ -1,6 +1,8 @@
 <?php
 
 use Flow\ParsoidUtils;
+use Flow\Exception\WikitextException;
+
 
 class ApiParsoidUtilsFlow extends ApiBase {
 
@@ -8,9 +10,16 @@
                $params = $this->extractRequestParams();
                $page = $this->getTitleOrPageId( $params );
 
+               try {
+                       $content = ParsoidUtils::convert( $params['from'], 
$params['to'], $params['content'], $page->getTitle() );
+               } catch ( WikitextException $e ) {
+                       $code = $e->getErrorCode();
+                       $this->dieUsage( $this->msg( $code 
)->inContentLanguage()->useDatabase( false )->plain(), $code );
+               }
+
                $result = array(
                        'format' => $params['to'],
-                       'content' => ParsoidUtils::convert( $params['from'], 
$params['to'], $params['content'], $page->getTitle() ),
+                       'content' => $content,
                );
                $this->getResult()->addValue( null, $this->getModuleName(), 
$result );
        }

-- 
To view, visit https://gerrit.wikimedia.org/r/107749
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I646322a03de9e82039d9744617b86716e37319ff
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>
Gerrit-Reviewer: Anomie <[email protected]>
Gerrit-Reviewer: EBernhardson <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Matthias Mullie <[email protected]>
Gerrit-Reviewer: Werdna <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to