0

Hi all I know its a stupid question but I'm trying everything.
My game server show me a very long error which is too long for console and can see the top of it, but it is missing from my log and I can't see the details of this error.
Can somebody help me on how can I capture that error:

private void fix(L2PcInstance pl, int playerPoints)
{
    try
    {
        IAchievement arc = Achievements.getInstance().GetAchivment(_id, pl.getAchivmentLevelbyId(_id) + 1);
        if ((arc != null) && (playerPoints > arc.getNeedPoints()))
        {
            Achievements.getInstance().reward(pl, arc);
            fix(pl, playerPoints);
        }
    }
    catch (Exception e)
    {
        _log.error(getClass().getSimpleName() + ": Error in fix: " + e);
    }
}

the error error console

the line 96 is

fix(pl, playerPoints);

but the error is missing from my log im try to capture the console to txt file from command

java myserver.jar > capturemyconsole.txt but again it's showing error in console that the txt is missing. How is this possible ? Thanks for your time and help :) and sorry for my bad english :(

John Moutafis
  • 22,254
  • 11
  • 68
  • 112
Micr0
  • 23
  • 5

2 Answers2

0

You method fix calls itself, with the same arguments, causing stack overflow...

Should add some modification to the arguments, or some more condition to the recursion...

Usagi Miyamoto
  • 6,196
  • 1
  • 19
  • 33
  • In fact, there should be argument modifications, and a base case, so you can stop the recursion. – Shirkam Aug 01 '17 at 10:08
  • this method is the real name "fix" fix method fixed in game the point on player its real name of the method – Micr0 Aug 01 '17 at 10:08
  • Sorry but I don't understand what you mean by this method is fixed in game. Could you please try the command in comment of bracco23 and show us the root of the stacktrace? If this really is a stackoverflow and the program is meant to work the way you source code describes it, you may should think of your overall design e.g. calling fix() in a loop and not via recursion. – Lars Aug 01 '17 at 10:15
  • yes im try now wait for the error i dont know when show thanks for fast anwser – Micr0 Aug 01 '17 at 10:20
0

You can catch "Error" instead of "Exception" and then log

[...] catch (Error e)
{
    _log.error(getClass().getSimpleName() + ": Error in fix: " + e, e);
}

In Your current code StackOverflowException (which is not a child of Exception) is propagated without going into catch block. Remember to put additional "e" parameter to log full stacktrace. It's not a good practice to catch Error, but it'll answer Your question.

More info: try/catch on stack overflows in java?

cyprian
  • 351
  • 3
  • 8