Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion zutil/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
- `\zutil_debug_generate_variant:Nn`

## `softerror` module
- new `l3msg` message level `softerror`
- new `l3msg` message class `softerror`
- like `error`, it uses both `⟨text⟩` and `⟨more text⟩` of a message
- like `warning`, it doesn't interrupt processing nor prompting for user input, thus produces portable and compact messages
- it's most suitable for log-based tests
Expand Down
13 changes: 7 additions & 6 deletions zutil/testfiles/zutil-softerror.lvt
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@
\zutil_msg_softerror:nnnnnn { __test } { 4-arg } { arg1 } { arg2 } { arg3 } { arg4 }
}

\OMIT
\msg_redirect_module:nnn { __test } { error } { softerror }
\TIMO

\TEST{softerror,~redirected}{
\msg_error:nn { __test } { short }
\msg_error:nn { __test } { long }
\msg_redirect_module:nnn { __test } { error } { softerror }
\msg_error:nnnnnn { __test } { 4-arg } { arg1 } { arg2 } { arg3 } { arg4 }

\msg_redirect_module:nnn { __test } { softerror } { info }
% now both error and softerror messages are redirected to info
\msg_error:nnnnnn { __test } { 4-arg } { arg1 } { arg2 } { arg3 } { arg4 }
\zutil_msg_softerror:nnnnnn { __test } { 4-arg } { arg1 } { arg2 } { arg3 } { arg4 }
\prop_show:N \l__msg_redirect_softerror_prop
}

\END
13 changes: 8 additions & 5 deletions zutil/testfiles/zutil-softerror.tlg

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 21 additions & 12 deletions zutil/zutil-softerror.code.tex
Original file line number Diff line number Diff line change
@@ -1,27 +1,36 @@
\ProvidesExplFile {zutil-softerror.code.tex} {2025-10-03} {0.1}
{Z's utilities, the softerror module}

% This module provides a new l3msg message level "softerror".
% Softerror is a combination of "warning" and "error":
% - Its message is formed like warning, using an error header;
% - Like error, it uses both the <text> and <more text> of a message, but
% it does not interrupt the processing, nor prompt for user input.
% By producing engine-neutral compact message, softerror is most suitable
% This module provides a new l3msg message class "softerror".

% Softerror is error without interruption:
% - Its message is formed like error, using both the <text> and <more text>
% of a message.
% - Unlike error, it does not interrupt the processing, nor prompt for user
% input, thus produces no interruption context.
%
% Due to its clean and compat engine-neutral output, Softerror is most suitable
% for log-based testing.
%
% Restricted by mechanism, there cannot be expandable softerrors.

% see \@@_class_new:nn definition and its usage \@@_class_new:nn { warning }
% (@@=msg) in l3msg.dtx for more info

% used by \msg_redirect_class:nn and \msg_redirect_module:nnn
\prop_new:N \l__msg_redirect_softerror_prop % noqa: w415

% new message level "softerror"
\cs_new_protected:Npn \__msg_softerror_code:nnnnnn #1#2#3#4#5#6
{
\__msg_softerror_aux:NNnnnnnn \iow_term:n \msg_softerror_text:n
{#1} {#2} {#3} {#4} {#5} {#6}
}

\prop_new_linked:N \l__msg_redirect_softerror_prop % noqa: w415

\cs_new:Npn \msg_softerror_text:n { !~\msg_error_text:n }

% based on \__msg_info_aux:NNnnnnnn, but also uses <more text> (content
% of the 4th arg of \msg_new:nnnn), like how \__msg_interrupt:NnnnN does
% based on \@@_info_aux:NNnnnnnn, but also uses <more text>, like how
% \@@_interrupt:NnnnN does (@@=msg). <more text> is the #4 argument passed to
% \msg_new:nnnn.
\cs_new_protected:Npn \__msg_softerror_aux:NNnnnnnn #1#2#3#4#5#6#7#8
{
\str_set:Ne \l__msg_text_str { #2 {#3} }
Expand Down Expand Up @@ -74,7 +83,7 @@
\cs_new_protected:Npn \zutil_msg_softerror:nn #1#2
{ \zutil_msg_softerror:nnnnnn {#1} {#2} { } { } { } { } }

% e-type variants correspond to those provided by expl3
% variants correspond to those provided by expl3, except for "deprecated" x-type ones
\cs_generate_variant:Nn \zutil_msg_softerror:nnn
{ nnV , nne }
\cs_generate_variant:Nn \zutil_msg_softerror:nnnn
Expand Down
Loading