lasterror -- reproduce the
last error
Introductionlasterror() reproduces the last error that
occurred in the current MuPAD session.
Call(s)lasterror()
Related
Functions
Detailslasterror is used to reproduce errors that
were caught by traperror. Cf. example 2.lasterror is a function of the system kernel.
Example
1We produce an error:
>> x := 0: y := 1/x
Error: Division by zero
This error may be reproduced by
lasterror:
>> lasterror()
Error: Division by zero
A further error is produced:
>> error("my error")
Error: my error
>> lasterror()
Error: my error
>> delete x, y:
Example
2The following procedure mysin computes the
sine function of its argument. In case of an error produced by the
system function sin, it
prints information on the argument and reproduces the error:
>> mysin := proc(x)
local result;
begin
if traperror((result := sin(x))) = 0 then
return(result)
else
print(Unquoted, "the following error occurred " .
"when calling sin(".expr2text(x)."):");
lasterror()
end_if:
end:
Indeed, the system's sine function produces an error for large floating point arguments:
>> mysin(1.0*10^100)
the following error occurred when calling sin(10.0e99):
Error: Loss of precision;
during evaluation of 'sin'
>> delete mysin: