Intel® Simics® Simulator for Intel® FPGAs: User Guide

ID 784383
Date 11/16/2024
Public
Document Table of Contents

8.1.7. Error Handling in Scripts

When an Intel® Simics® simulator command encounters an error, an error message is typically printed, and the script execution is interrupted. In some cases, the script itself may want to handle the error to try some alternative approach, or to present the error message with more context. You can use the try-except statement for this purpose.

The following capture shows an example that demonstrates the use of the try-except command:

#Intel Simics simulator CLI 

simics> try {
....... load-module my-own-components
....... } except {
....... echo "
               Intel® 
               Simics®
             failed to import my-own-components. "
....... echo "Please make sure that the component is installed!"
....... echo "Error: " 
....... get-error-message
....... }

Intel Simics failed to import my-own-components.  
Please make sure that the component is installed!
Error: 
"Unknown module: my-own-components"
simics> load-module my-own-components

Unknown module: my-own-components

The error message from the failing command can be obtained inside the except block by calling the get-error-message CLI command, as shown in the example. The get-error-line command returns the line of the error in the script file and get-error-file returns the file name. The get-error-command returns the command name if the error occurred within a command.