Is there a way of curbing stack dumps on a simple error?

I have a rule that runs every minute and sends out a web query using Curl, it expects a JSON string to be returned which I then parse to get out the value I want. Unfortunately if this comes back empty because the distant website didn’t respond I get a 50 line stack dump of largely useless text.
Is there a way of trimming this logging back so I only get the meaningful first line which is:
2015-12-01 05:08:35.094 [ERROR] [.o.m.r.i.engine.ExecuteRuleJob] - Error during the execution of rule Update Heatpump Switches
java.lang.IllegalArgumentException: json string can not be null or empty

Personally, I’d simply check to see if the string is empty before passing it to the JSON parser and eliminate the error entirely.

But if you want to modify the logging see the Logback documentation.

You can also wrap your JSON parsing code in a try…catch statement to catch and process the error internally within your rule, e.g:

try {
    // do JSON parsing here
} catch(Throwable t) {
    logError("MyRule", "Funky JSON error occured: {}", t)
}

HTH.

Thanks for the suggestion, can you advise how?
The command that gets the string is
var OfficeHeatpumpStatus = executeCommandLine(‘curl -sSH “Accept: application/json” “https://webaddress?apiKey=myapi&limit=1&fields=acState”’, 5000)

if(OfficeHeatpumpStatus != ""){
    // parse the JSON
}

To do the exception handling

try {
    var OfficeHeatpumpStatus = executeCommandLine('curl -sSH "Accept: application/json" "https://webaddress?apiKey=myapi&limit=1&fields=acState"', 5000)
    // parse JSON
}
catch(Throwable t) {
    logError("MyRule", "Funky JSON error occured: {}", t)
}

Thanks Rich and Rob,
I’ll add the above to my rules and hopefully that’s the end of intermittent logs full of junk.
Cheers
Kevin

To update this for those following later, last night the error happened again and the fix worked perfectly. The fix was putting the text below around the whole rule.

try {
// do JSON parsing here
} catch(Throwable t) {
logError(“MyRule”, “Funky JSON error occured: {}”, t)
}

I have a problem similar to a broker integrated in a Victron inverter.
Sometimes it sends “empty” messages or “null” and I get this error:

java.lang.IllegalArgumentException: json string can not be null or empty
        at com.jayway.jsonpath.internal.Utils.notEmpty(Utils.java:383)
        at com.jayway.jsonpath.internal.ParseContextImpl.parse(ParseContextImpl.java:36)
        at com.jayway.jsonpath.JsonPath.read(JsonPath.java:498)
        at org.openhab.transform.jsonpath.internal.JSonPathTransformationService.transform(JSonPathTransformationService.java:63)

Could a rule be created to ignore all “null” and “empty” messages coming from the Victron mqtt broker?
Thank you

it’s not complicated

if (myresponsestring !== null) {
    //process it
} else {
   logInfo("myRule", "I got null json this time")
}

This is my exemple topic

N/c06jfhsdjfh6fe/pvinverter/20/Ac/Power {"value": 2450.00} - OK topic 
N/c06jfhsdjfh6fe/pvinverter/20/Ac/Power                 -  Empty topic
N/c06jfhsdjfh6fe/pvinverter/20/Ac/Power {NULL}    - NULL topic