Olalekan
Olalekan

Reputation: 475

How to get syntax error on Ace editor and alert it

I have been trying to customise syntax error on Ace editor. I disabled live syntax checker using this code below

 editor.getSession().setUseWorker(false);

I have googled and try several answers on stackoverflow, no one of these work.

I want to get syntax error like

if there is error or warning

  1. On click run button
  2. Get editor error or warning
  3. Append it in a bootstrap alert div
  4. Return false (do not run the code).

Please i need help. I am ready to learn it step by step.

Upvotes: 3

Views: 5725

Answers (1)

Olalekan
Olalekan

Reputation: 475

I follow syntax issue created on Ace github and add some answers i got on stackoverflow.

Here his how i fix it

editor.getSession().on("changeAnnotation", function () {
  var annot = editor.getSession().getAnnotations();

  for (var key in annot) {
    if (annot.hasOwnProperty(key))
      console.log(annot[key].text + "on line " + " " + annot[key].row);
  }
});

Upvotes: 11

Related Questions