question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Go target, unable to check when custom error strategy is in recovery mode

See original GitHub issue

Hello, community!

I am trying to move existing parser error strategy from c++ to golang target:

class MyErrorStrategy: public antlr4::DefaultErrorStrategy {
  void reportUnwantedToken(antlr4::Parser* recognizer) override {
    if (inErrorRecoveryMode(recognizer)) {
      return;
    }

    antlr4::Token* t = recognizer->getCurrentToken();
    std::string tokenName = getTokenErrorDisplay(t);
    antlr4::misc::IntervalSet expecting = getExpectedTokens(recognizer);

    throw CustomException({
      {"extraneous input " + tokenName, Position {int(t->getLine()), int(t->getCharPositionInLine()) + 1}},
      {" expecting " + expecting.toString(recognizer->getVocabulary()), Position()}
    });
  }
};

But I have a “small problem”. Unlike c++, golang does not provide the ability to call private / unexported methods. This small difference makes it impossible to check when the strategy is inErrorRecoveryMode.

I saw that the strategy method GetTokenErrorDisplay was made public, as well as the parser method GetCurrentToken in contrast to the c++ runtime, where it has private access. Perhaps it’s time to also make the inErrorRecoveryMode method public? I find an explanation why the methods of controlling the state flag are private, but I don’t understand why method for reading it has private access.

I also assume that there is another way to do this check. If I’m right, please tell me how I can do it.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
parrtcommented, Feb 15, 2022

Weird. that it did not auto close to spite me saying “Fixes #3259”. hmm…

1reaction
jckingcommented, Feb 15, 2022

Yeah, it looks like it should be compared to other runtimes. SGTM

Read more comments on GitHub >

github_iconTop Results From Across the Web

how to write a custom error reporter in go target of antlr
This panic error is caught and passed to the ErrorHandler which implements ErrorStrategy . The important function we care about is Recover() ....
Read more >
Custom Error Handler Pages | Adobe Experience Cloud
Description. Environment Experience Manager. Issue/Symptoms How can I create custom scripts or error handlers that render different HTTP errors?
Read more >
Error Handling and Recovery Mechanisms is SAP Data ...
The Error log lists errors generated by Data Services, by the source or target DBMS, or the operating system. If the execution completed...
Read more >
Troubleshooting a failed canary - Amazon CloudWatch
If your canary fails, check the following for troubleshooting. General troubleshooting. Use the canary details page to find more information.
Read more >
Troubleshooting index lifecycle management errors - Elastic
Elasticsearch Guide: ... Snapshot and restore ... increase the number of shards, this operation fails and ILM moves my-index-000001 to the ERROR step....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found