Redesign of LAStools error handling

Release note for version 240510: The redesign of the error handling may require customization of scripts using LAStools.


The reasons for error messages can be minor (e.g. a tool argument is not in the correct range). However, especially when working in batch mode, it is crucial that errors in the process are reliably detected so that no data is used or published that contains errors or is incomplete. In the past, the only way to reliably determine whether an error situation existed was to analyze the output of the program console for the “ERROR” token. In addition, warnings were issued that must be viewed as errors and lead to the program being terminated immediately. This resulted in console outputs as follows:

llx/lly unspecified. set to lower left bounding box 535180/4.12958e+006.
ERROR (TINclean): failed malloc for 40610234 TINtriangles.
ERROR: cannot alloc enough TIN triangles to triangulate 20305117 points.
ERROR: cannot alloc enough TIN triangles to triangulate 26879983 points.

Already the first error led the program to stop because there was no chance of obtaining a valid result. Some months ago, LAStools was extended to define message classes, which made it easier for library functions to detect an error by message type (and not just text output). A common method in console applications is to use an exit code. This exit code was not always set correctly in LAStools. Therefore, it often remained at “0” for “success”, even if there were errors or warnings.


The error handling was completely redesigned, which also includes some significant changes to the program workflow. The new error handling principles are as follows:

  • All messages are classified into the categories „very verbose, verbose, information, warning, serious warning, error, fatal error“.
  • Warnings never stop the program, the exit code at the end of the program is set to „2“.
  • Serious warnings stop the program, unless the „-force“ argument is used.
  • In the event of an error, the program is immediately terminated with the exit code “3”.
  • The exit code „0“ means that no errors or warnings occurred during the execution of the program.

This fundamental change within the workflow will potentially change the behavior of existing batch programs and require action from users. However, it should be worthwhile for you to adapt your scripts to ensure continuous improvement in workflow results.

Exit codes

Every LAStools program now ends with a defined exit code. The exit code is defined by the highest message type that occurred during program run. Certain message types force the program to stop immediatly.

Message typeExit codeImmediate STOP
SERIOUS_WARNING2yes (default), no (-force argument)

ERRORs that did not stop the program in the past become a WARNING in the future, (e.g. in coordinate system interpretation). There were also a lot of ERRORs when something did not match with CRS, but the program continued to run. These will also become WARNINGs. The exit code of a program can be easily retrieved. The variable %errorlevel% can be used within the Windows console.

> las2las64 -abc
ERROR: cannot understand argument '-abc'. use -h or see to get help.
> echo %errorlevel%

Within a windows batch file, the variable can be used to control the program flow. Sample file „test.cmd“:

@echo off
las2dem64 -i test.laz
echo program exits with errorlevel=%errorlevel%
if "%errorlevel%"=="0" (
  echo "succeed"
  rem ... do this
) else (
  echo "failed"
  rem ... do that

Within linux bash

echo $?

can be used to get the program exit code.

Common extensions

Part of the redesign was also a common argument parser for all LAStools. This means that all common arguments such as „-v“, „-h“,… will behave identically in future. The „-fail“ argument is now part of all licensed tools. The tool exits with an „unlicensed“ error message instead of running in demo mode.

-h, -helpPrints information about the tool
-hhPrints information about the tool and the used modules
-v, -verbosePrints verbose log output
-vvPrints very verbose log output
-silentPrints only output on errors or warnings
-quietPrints no output at all
-forceContinue, even if serious warnings occur
-errors_ignoreContinue, even if errors occur (if possible). Use with caution!
-print_log_statsPrint additional log statistics:
Log stats: FE=0,E=1,SW=0,W=0,I=1
Where FE…I identifies the message type „fatal error“ … „information“
-guiRun with old graphical interface (if possible)
-versionPrint version and license summary and exit
-cpu64Run multi core processes in 64 bitOnly certain tools
-cores [n]Use [n] cores for multi processingOnly certain tools
-licensePrint license information and exitOnly licensed tools
-failFail if license is invalid (avoid running in demo mode)Only licensed tools

Help system

Our reference help system is the [toolname] files (like and laslook with the full argument database. Additionally, all tools have a „-h“ or „-help“ argument to display online help. This also resulted in all module arguments being printed and the actual arguments of the tool itself were not so easy to see. Now the „-h“ argument only prints the tool help. To also print the module arguments, the argument „-hh“ can be used.

Nach oben scrollen