[latex3-commits] [git/LaTeX3-latex3-latex2e] gh569: Add error recovery (780ca131)

PhelypeOleinik phelype.oleinik at latex-project.org
Mon Aug 9 01:40:32 CEST 2021


Repository : https://github.com/latex3/latex2e
On branch  : gh569
Link       : https://github.com/latex3/latex2e/commit/780ca13105a9171d32eb8ade2fe56db72f996646

>---------------------------------------------------------------

commit 780ca13105a9171d32eb8ade2fe56db72f996646
Author: PhelypeOleinik <phelype.oleinik at latex-project.org>
Date:   Sun Aug 8 20:40:32 2021 -0300

    Add error recovery


>---------------------------------------------------------------

780ca13105a9171d32eb8ade2fe56db72f996646
 base/ltcmd.dtx | 32 +++++++++++++++++++++++++++++---
 1 file changed, 29 insertions(+), 3 deletions(-)

diff --git a/base/ltcmd.dtx b/base/ltcmd.dtx
index 6f8fdf76..279fad50 100644
--- a/base/ltcmd.dtx
+++ b/base/ltcmd.dtx
@@ -886,9 +886,10 @@
           { \@@_copy_command:nnNN }
           { \@@_copy_expandable:nnNN }
           { \@@_copy_environment:nnNN }
-          { \exp_not:N \ERROR }
+          { \@@_cant_copy:nwn { non-ltcmd } }
             { \cs_to_str:N #1 } { \cs_to_str:N #2 }
             \exp_not:N #1 \exp_not:N #2
+        \exp_not:N \@@_break_point:n { \cs_to_str:N #2 }
         \int_set:Nn \tex_escapechar:D { \int_use:N \tex_escapechar:D }
       }
   }
@@ -897,6 +898,28 @@
 \cs_generate_variant:Nn \@@_set_eq_if_exist:NN { cc }
 %    \end{macrocode}
 %
+% \begin{macro}{\@@_cant_copy:nwn}
+%   An utility macro similar to \cs{@@_bad_def:wn} to abort a command
+%   copy.  Contrary to \cs{@@_bad_def:wn} though, when this happens the
+%   issue is most likely internal, because the command was already
+%   (supposedly) correcly defined so it should be copyable.  Hopefully
+%   this macro will never be used ever, but if it does, apologise and
+%   give the reason for the failure so the user can report.
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_cant_copy:nwn #1 #2 \@@_break_point:n #3
+  { \msg_error:nnnn { cmd } { copy-bug } {#1} {#3} }
+\msg_new:nnn { cmd } { copy-bug }
+  {
+    Internal~error~while~copying~command~\iow_char:N\\#2:\\
+    \str_case:nn {#1}
+      {
+        { non-ltcmd } { Command~is~not~a~valid~ltcmd~command. }
+        { unknown-type } { Found~an~unknown~argument~type. }
+      }
+  }
+%    \end{macrocode}
+% \end{macro}
+%
 %   And, of course, add \cs{__kernel_cmd_if_xparse:NTF} and
 %   \cs{@@_copy:NN} to \cs{@declarecommandcopylisthook}:
 %    \begin{macrocode}
@@ -1016,7 +1039,7 @@
         \tl_put_right:Nx \exp_not:N \l_@@_tmpa_tl
           { \exp_not:N \exp_not:c { @@_expandable_grab_##2:w } }
         \exp_not:N \cs_if_exist_use:cF { @@_copy_grabber_##2:w }
-          { \exp_not:N \ERROR }
+          { \@@_cant_copy:nwn { unknown-type } }
       }
   }
 %    \end{macrocode}
@@ -1092,7 +1115,10 @@
 %
 % \begin{macro}{\@@_copy_environment:nnNN}
 %    \begin{macrocode}
-\cs_new_protected:Npn \@@_copy_environment:nnNN #1 #2 #3 #4 { \ERROR }
+\cs_new_protected:Npn \@@_copy_environment:nnNN #1 #2 #3 #4
+  { \msg_error:nn { cmd } { env-copy } }
+\msg_new:nnn { cmd } { env-copy }
+  { Copying~environments~is~not~possible. }
 %    \end{macrocode}
 %
 %<latexrelease>\EndIncludeInRelease





More information about the latex3-commits mailing list.