--- loncom/xml/lontex.pm 2023/12/22 13:38:01 1.14 +++ loncom/xml/lontex.pm 2025/02/20 00:41:11 1.15 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # TeX Content Handler # -# $Id: lontex.pm,v 1.14 2023/12/22 13:38:01 raeburn Exp $ +# $Id: lontex.pm,v 1.15 2025/02/20 00:41:11 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -46,12 +46,14 @@ use Apache::File; use Apache::lontexconvert; use Apache::Constants qw(:common); use Apache::lonnet; +use Apache::loncommon; +use Apache::lonmsg; +use Apache::lonlocal; use tth; # ================================================================ Main Handler sub footer { - my ($errorstring) = @_; my $xmlstring=''; if ($env{'request.state'} eq 'construct') { $xmlstring.='
'. @@ -84,8 +86,21 @@ sub handler { # ------------------------------------------------------------------- Read file { - my $fh=Apache::File->new($r->filename); - @texcontents=<$fh>; + if (-e $r->filename) { + my $fh=Apache::File->new($r->filename); + @texcontents=<$fh>; + close($fh); + } else { + my $filename=(split('/',$r->filename))[-1]; + my $error = + '' + .&mt('Unable to find [_1]', + ''.$filename.'') + ."
"; + &Apache::loncommon::simple_error_page($r,'Not available', + $error,{'no_auto_mt_msg' => 1}); + return OK; + } } $texstring=join("\n",@texcontents);