Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
2025.0.0 - English


lasterror

get last recorded error message

Syntax

[str,n,line,func] = lasterror()
[str,n,line,func] = lasterror(opt)

Arguments

str

a vector of character strings or an empty matrix. The last recorded error message.

n

an integer, 0 or the last recorded error number.

line

an integer, 0 or the last recorded function line number.

func

a string, the last recorded function name.

opt

a boolean, if %t recorded message is cleared. Default is %t.

Description

Each time an error occurs, the Scilab error handler records it in an internal table (only the last one is retained). The lasterror function allows to get the message, the error number, the current function (if any) and the current line number in the current function out of this table.

The reported line number is the physical line number where the last error occurred. Note that Scilab versions before 5.0 used to report the logical line number of the last error. There is a difference only if the function in error includes continued lines (see dot) before the point where the error happened.

This function is especially useful while using execstr.

The recorded error message may be retained for a further call to lasterror using lasterror(%f).

Examples

ierr=execstr('a=zzzzzzz','errcatch')
if ierr>0 then
  disp(lasterror())
end

See also

  • execstr — execute Scilab code in strings
  • error — reports a run time error
  • errclear — clears the last error (if its number matches a given one)
  • edit_error — opens in scilab editor the source of the last recorded error
Report an issue
<< error_table Error handling warning >>

Copyright (c) 2022-2024 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Thu Oct 24 11:13:05 CEST 2024