casual Posted August 24, 2015 Posted August 24, 2015 What's the general rule of thumb at debugging scripts? What I do is - realize it's buggy - log out of client - rewrite one line - recompile - copy to scripts folder - relauch client - log in to account manually - start script - GOTO 1; It takes more than a minute. I'm getting a mysterious error in onStart() and I can locate which method causes it. I can't get a clearer error message though. The error must be that widget child/grandchild IDs do not always match, and cant't figure out why.
Precise Posted August 24, 2015 Posted August 24, 2015 (edited) What's the general rule of thumb at debugging scripts? What I do is - realize it's buggy - log out of client - rewrite one line - recompile - copy to scripts folder - relauch client - log in to account manually - start script - GOTO 1; It takes more than a minute. I'm getting a mysterious error in onStart() and I can locate which method causes it. I can't get a clearer error message though. The error must be that widget child/grandchild IDs do not always match, and cant't figure out why. are you null checking them? post the code Edited August 24, 2015 by Precise
Flamezzz Posted August 24, 2015 Posted August 24, 2015 You don't have to relaunch the client. Configure an artifact (or w/e it's called in your IDE) in the script folder and your IDE will replace it after each compilation. So all you have to do is refresh and restart the script.I think it's possible to just catch any exception in onStart and print its message.try {....} catch(Exception e) { if(e.getMessage() != null) log(e.getMessage());}
casual Posted August 24, 2015 Author Posted August 24, 2015 (edited) I'll google for this artifact stuff. Here's the current messy code. public int getPriceOnTheRight() throws InterruptedException{ RS2Widget rightside = widgets.get(465, 23, 39); if(rightside != null){ // log(rightside.getMessage()); // maybe this has no getMessage method, how to check this? String msg = rightside.getMessage(); // the error is thrown here I guess if(msg != null){ return Integer.parseInt(msg.replace(" coins", "")); }else{ log("getMessage didnt find any text"); return 0; } }else{ log("Right side widget area not found"); return 0; } } Edited August 24, 2015 by casual
liverare Posted August 24, 2015 Posted August 24, 2015 "copy to scripts folder." If you're using Eclipse, here's my guide on how to solve that. 2
Joseph Posted August 24, 2015 Posted August 24, 2015 What's the general rule of thumb at debugging scripts? I'm getting a mysterious error in onStart() and I can locate which method causes it. I can't get a clearer error message though. The error must be that widget child/grandchild IDs do not always match, and cant't figure out why. put a log between each line and see which line was last called. Anything under that is where the problem is coming from
casual Posted August 24, 2015 Author Posted August 24, 2015 (edited) I mean isn't there a stack trace or something I could enable? noone likes these bruteforce woodchopping style debugs Edited August 24, 2015 by casual
Zee Best Posted August 26, 2015 Posted August 26, 2015 (edited) As others have said wrap your onStart method in a try catch statement. You could print the track stace like; try { /* YOUR CODE HERE */ } catch(final Exception e) { final StackTraceElement[] stack = e.getStackTrace(); for (final StackTraceElement ste : stack) log(ste.getMessage()); } The only area I can see any error potentially being thrown there is your Integer.parseInt, make sure that the text doesn't have trailing or leading whitespace, you can use .trim() to ensure that. Also, print it out to see what it's actually trying to parse to ensure it's not going to throw a NumberFormatException. Edited August 26, 2015 by Zee Best