Previous Page Next Page Contents

lasterror -- reproduce the last error

Introduction

lasterror() reproduces the last error that occurred in the current MuPAD session.

Call(s)

lasterror()

Related Functions

error, traperror

Details

Example 1

We 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 2

The 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:

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000