I would like to do some error checking from within an expandable function. But my attempts at signalling an error are not processed correctly, but rather returned to the input stream---contrary to my expectations.
Here's the code:
\documentclass{article}
\usepackage{pstricks,pst-eucl}
\psset{unit=0.25cm}
\usepackage{xparse}
\ExplSyntaxOn
\msg_new:nnnn {testing}{testing}{illegal~property}{}
%% property list
\prop_new:N \g__ace_all_properties_plist
%% setter
\cs_new_protected:Npn \__ace_set_property:nn #1#2
{
\prop_gput:Nnn \g__ace_all_properties_plist { #1 } { #2 }
}
%% getter
\cs_new:Npn \__ace_get_property:n #1
{
\prop_get:Nn \g__ace_all_properties_plist { #1 }
}
%%--- User interface for settr and gettr
\DeclareDocumentCommand{\settr}{ m m }
{
\__ace_set_property:nn { #1 }{ #2 }
}
\DeclareExpandableDocumentCommand{\gettr}{ m }
{
\prop_if_in:NnTF \g__ace_all_properties_plist { #1 }
{
\__ace_get_property:n { #1 }
}
{
%% this next line does not get executed
%% even when there #1 is not in the list
%<var 1>%\msg_info_text:n { #1 ~ is ~ not ~ defined }
\msg_fatal_text:n { testing}
}
}
\ExplSyntaxOff
\pagestyle{empty}
\begin{document}
\settr{displacement}{10}%
This picture gets processed correctly\par
\begin{pspicture}(0,0)(10,10)
\pstGeonode[PointName=default,PointSymbol=default,PosAngle=0](0,0){A}(0,1){B}
\pstTranslation[DistCoef=\gettr{displacement}]{A}{B}{A}[C]
\end{pspicture}
\vspace{1cm}
No error signaled here $\rightarrow$
\gettr{unknownproperty}
\vspace{1cm}
This picture should signal an error when commented line uncommented\par
\begin{pspicture}(0,0)(10,10)
\pstGeonode[PointName=default,PointSymbol=default,PosAngle=0](0,0){A}(0,1){B}
%\pstTranslation[DistCoef=\gettr{unknown-property}]{A}{B}{A}[C]
\end{pspicture}
\end{document}
Initially, I thought this was an issue of calling a protect function \msg_term:x from within an expandable function. But, my errors are not properly triggered even when using using \mgs_fatal_text:n. This later approach is not really what I want. But signalling an error in any way would be nice.
EDIT
Following @DavidCarlisle's suggestion, I tried replacing
\msg_fatal_text:n{ testing }
with
\ERROR
So, the compilation stops, but since the wrong type of error message is signaled, I can imagine wasting a lot of time looking for the wrong error. So, instead of \ERROR I tried
\use:c { Attempting ~ to ~ call ~ undefined ~ property -> {#1} }
I figured at least with this, I'd get an error that made it clearer what the real issue was. But this doesn't signal an error at all---contrary to my expectations.

\use:cis just\csname ...\endcsnamehidden. This also doesn't trigger an error when the csname doesn't exist but defines it to be equal to\relax– cgnieder Feb 10 at 16:19\csname phantomsection\endcsnamewon't do harm ifhyperrefis not loaded.) How about an undefined\undefinedproperty? – cgnieder Feb 10 at 16:23\__msg_kernel_expandable_error:nnnand\__msg_expandable_error:nthat don't have, at least for now, a "programmer's level" interface. – egreg Feb 10 at 17:02