Patchwork [6,of,7] templater: specialize ResourceUnavailable error so that it can be caught

login
register
mail settings
Submitter Yuya Nishihara
Date Feb. 26, 2018, 2:29 p.m.
Message ID <02afa73e633146722c18.1519655379@mimosa>
Download mbox | patch
Permalink /patch/28412/
State Accepted
Headers show

Comments

Yuya Nishihara - Feb. 26, 2018, 2:29 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1519530630 -32400
#      Sun Feb 25 12:50:30 2018 +0900
# Node ID 02afa73e633146722c187090fd73885fceb552d9
# Parent  35263744d42f5a3c60faec304d044cbee337599d
templater: specialize ResourceUnavailable error so that it can be caught

See the next patch how it will be used.

Patch

diff --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -30,6 +30,9 @@  from . import (
     util,
 )
 
+class ResourceUnavailable(error.Abort):
+    pass
+
 class TemplateNotFound(error.Abort):
     pass
 
@@ -1377,7 +1380,8 @@  class engine(object):
         if v is None:
             v = self._resources.get(key)
         if v is None:
-            raise error.Abort(_('template resource not available: %s') % key)
+            raise ResourceUnavailable(_('template resource not available: %s')
+                                      % key)
         return v
 
     def _load(self, t):