Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c6ab4ab

Browse files
author
Ulrich J. Herter
committed
Using self.error in drective to provide context.
1 parent 1d6e939 commit c6ab4ab

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lib/matplotlib/sphinxext/plot_directive.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,11 @@ class PlotDirective(Directive):
250250

251251
def run(self):
252252
"""Run the plot directive."""
253-
return run(self.arguments, self.content, self.options,
254-
self.state_machine, self.state, self.lineno)
253+
try:
254+
return run(self.arguments, self.content, self.options,
255+
self.state_machine, self.state, self.lineno)
256+
except Exception as e:
257+
raise self.error(str(e))
255258

256259

257260
def setup(app):
@@ -649,9 +652,8 @@ def run(arguments, content, options, state_machine, state, lineno):
649652
'Caption specified in both content and options.'
650653
' Please remove ambiguity.'
651654
)
652-
else:
653-
# Use caption option
654-
caption = options["caption"]
655+
# Use caption option
656+
caption = options["caption"]
655657

656658
# If the optional function name is provided, use it
657659
if len(arguments) == 2:

0 commit comments

Comments
 (0)