Error handling in Exec plugin

I am executing a script using [[input.exec]] and want to handle error in the script in graceful way. As the exec plugin can parse the output of the script either in “influx” or “json” wondering if there is any better way to inform telegraf that script failed because of some reason.
Example use case : I have a multiple scripts that connect to different services using credentials and those scripts process response and converts it into json/influx format and emits to exec plugin. Is there a way if script can send error message to exec plugin so that it gives proper error message instead of parsing error?

If you write an error message to stderr and exit with a non-zero status code Telegraf will include the message in its logging output.

Thanks Daniel, it worked.