Scilab Java integration: Exception handling?

48 views Asked by At

I am working with Scilab Java integration, i. e. calling Java classes within Scilab to do some external device communication. I am using Scilab 2023.1.0 and OpenJDK jdk8u352-b08 to compile the java classes. When my Java code causes an exception, I do not get the information about what is wrong.

Example java code:

public class DScope
{

    public void exceptiontest(int val) throws Exception
    {
        System.err.println("Inspecting: '" + val + "'");
        if (val < 0)
        {
            throw new Exception("value is <0");
        }
        
    }
}

Scilab result:

--> myDScope = DScope.new();

--> myDScope.exceptiontest(8)

--> myDScope.exceptiontest(-8)

Undefinierte Operation für die gegebenen Operanden.
Funktion %eo_e für Überladung prüfen oder definieren.

I also tried to output some information with System.err.println, but this does not reach the Scilab console.

1

There are 1 answers

2
drino On

Have you tried to throw a RuntimeException ? That could be helpful in order to identify the origin of the problem.

I would also try to print in out rather that err.

Try folowwing code :

public class DScope
{
    public void exceptiontest(int val)
    {
        System.out.println("Inspecting: '" + val + "'");
        if (val < 0)
        {
            throw new RuntimeException("value is <0");
        }
    }
}