Datasource plugin dev: validate query and report error

I’m developing a datasource plugin. I would like to validate my query, and show error in the query editor. Is there a standard way of reporting the validation error? I believe this is a common feature of the ds plugins. A link to Github would be great.

Some of my ideas are

  • validate the entire query in the onChange(query) of my QueryEditor.
  • if it’s valid call onRunQuery()
  • if it’s invalid do not call it. Then show error (how?)

Thanks

The solution is to throw an error from anywhere in the query() method. The message doesn’t seem to take formatting.

throw {
   status: "error",
   message: "error message"
}