Panel data error: TypeError: Cannot read property 'emit' of undefined

I would like to show error under the query editor panel and let say i have a case where I am emitting an error from datasourse.js and handling it in query_ctrl.js.

But whenever I try to emit on ‘data-error’, i am getting emit of undefined error.

This is the code from datasource.js

try {
      var result = JSONPath({json: data, path: target.jsonQuery});
} catch(err) {'data-error', err);

This is how I am handling the received error from query_ctrl.js'data-error', this.onDataError.bind(this), $scope);

    onDataError(err) {
        // i am handling the error here