News for hackers. Stuff that matters.
Re:Ask HN: What is your best advice for a junior software de... by fhood on Wednesday October 03, 2018 @11:43AM (#18131349)
It isn't just a huge hint, most of the time it tells you exactly what the damn issue is. This discussion is blowing my mind.

I am honestly speechless. IT GIVES YOU THE LINE NUMBER AND THE FUNCTION CALL AND THE REASON! Why would you ever even attempt to debug without parsing it?

Re:Ask HN: What is your best advice for a junior software de... by eitland on Wednesday October 03, 2018 @12:19PM (#18131784)
Wait wait wait.

Not so fast.

i'm one of those programmers who read manuals and stack traces but I have to admit that I've seen my share of both manuals as well as stack traces that didn't make much sense.

Re:Ask HN: What is your best advice for a junior software de... by kickopotomus on Wednesday October 03, 2018 @01:16PM (#18132426)
This is my experience with Clojure stack traces ~60-75% of the time. Perhaps it is a symptom of functional programming? A lot of function passing and anonymous functions make it difficult to generate a meaningful stack trace.
Re:Ask HN: What is your best advice for a junior software de... by lmkg on Wednesday October 03, 2018 @02:05PM (#18132933)
Clojure's stack traces are an issue with Clojure specifically, and how it's hosted on top of the JVM. A lot of the stack trace you get is actually implementation details of the Java objects making up the Clojure runtime. In effect, the program that you get stack traces of is the Clojure interpreter rather than your Clojure program which is running inside that interpreter.
Re:Ask HN: What is your best advice for a junior software de... by vram22 on Wednesday October 03, 2018 @04:32PM (#18134574)
Why do they do this, though? Shouldn't they have realized from the start that such messages are not helpful, and should have given messages related to your Clojure program? (Or is there some difficult technical issue related to achieving this?)

Asking because reading about this issue in the past is one thing that has kept me from trying out Clojure.

Re:Ask HN: What is your best advice for a junior software de... by konamicode on Wednesday October 03, 2018 @04:21PM (#18134468)
I've heard similar things about Scala, though I haven't had a chance to confirm this for myself yet. Not 100% sure if this supports your hypothesis or not given that Scala is multiparadigm?
Re:Ask HN: What is your best advice for a junior software de... by projectileboy on Wednesday October 03, 2018 @03:54PM (#18134192)
Fortunately, I think 1.10 is going a long way towards fixing this.
Re:Ask HN: What is your best advice for a junior software de... by avhon1 on Wednesday October 03, 2018 @04:06PM (#18134327)
My experience in Racket has been the opposite. Especially with the aid of DrRacket's stepping debugger, reading stack traces and finding bugs is rather painless. (Figuring out the best way to fix bugs, however, is no easier than in any other language.)
Re:Ask HN: What is your best advice for a junior software de... by quaunaut on Wednesday October 03, 2018 @03:50PM (#18134137)
Functional programming not so much- languages like Elixir or JS used functionally don't have this problem generally.
Re:Ask HN: What is your best advice for a junior software de... by mercer on Sunday October 07, 2018 @09:00AM (#18160345)
Elixir has had difficult to parse error messages until relatively recently, but this has improved immensely (Dialyzer/Dialyxir in particular).
Re:Ask HN: What is your best advice for a junior software de... by quaunaut on Monday October 08, 2018 @01:37PM (#18169483)
In what way? I've been using Elixir since late 2015 and have rarely had issues.
Re:Ask HN: What is your best advice for a junior software de... by dave_sid on Thursday October 04, 2018 @03:53AM (#18137967)
Yeah I agree. The way this thread is going you would think that all errors are easy and all you have to do is what the computer tells you and you’re done. I wish I’d known it was all that simple!
Re:Ask HN: What is your best advice for a junior software de... by TimTheTinker on Wednesday October 03, 2018 @12:40PM (#18132022)
> stack traces that didn't make much sense.

Those can be especially prevalent in systems that utilize a lot of indirection.

Re:Ask HN: What is your best advice for a junior software de... by _mdpn on Wednesday October 03, 2018 @03:49PM (#18134126)
Especially when you end up in C++ template hell.
Re:Ask HN: What is your best advice for a junior software de... by NeoBasilisk on Wednesday October 03, 2018 @06:32PM (#18135371)
That kind of stuff permanently damaged my ability to enjoy using C++.
Re:Ask HN: What is your best advice for a junior software de... by samnardoni on Wednesday October 03, 2018 @05:07PM (#18134827)
Error in boost/bind.hpp:768
Re:Ask HN: What is your best advice for a junior software de... by dba7dba on Wednesday October 03, 2018 @12:41PM (#18132037)
That's exactly what I felt as I was spending time on MSDN/Microsoft support website, reading about weird errors messages on Windows 95/98/NT/XP in 1990s. Some generic desc about the Windows error messages and no resolution.
Re:Ask HN: What is your best advice for a junior software de... by tyrex2017 on Thursday October 04, 2018 @08:46AM (#18139364)
as in tensorflow stack traces
Re:Ask HN: What is your best advice for a junior software de... by dsr_ on Wednesday October 03, 2018 @11:48AM (#18131419)
And in the opposite direction: remember when you are writing error messages to include all the relevant details, and never ever write "this shouldn't happen" or "document later".
Re:Ask HN: What is your best advice for a junior software de... by fhood on Wednesday October 03, 2018 @11:52AM (#18131459)
What about, log_panic("If we have somehow managed to hit this code path, this project if FUBAR. I would recommend giving up and starting over.")
Re:Ask HN: What is your best advice for a junior software de... by btschaegg on Thursday October 04, 2018 @02:02AM (#18137539)
Somehow reminds me of Aliens:

  I say we take off and nuke the entire site from orbit. It's the only way to be sure.
:-)
Re:Ask HN: What is your best advice for a junior software de... by m_samuel_l on Wednesday October 03, 2018 @06:05PM (#18135231)
That's annoying but fine as long as it's unique and you can grep it in the codebase.
Re:Ask HN: What is your best advice for a junior software de... by fao_ on Wednesday October 03, 2018 @07:18PM (#18135615)
You can forgo something being unique if you just append line and file information to the log. Literally any logging framework (even homerolled ones) should give you this by default.
Re:Ask HN: What is your best advice for a junior software de... by fhood on Thursday October 04, 2018 @11:00AM (#18140486)
yup
Re:Ask HN: What is your best advice for a junior software de... by pletnes on Wednesday October 03, 2018 @12:41PM (#18132033)
If used correctly, «this should not happen» can be very useful, indicating e.g that the program is in some illegal state, as opposed to the input being incorrectly formatted.
Re:Ask HN: What is your best advice for a junior software de... by scarface74 on Wednesday October 03, 2018 @01:24PM (#18132504)
Even if that’s the case, create a custom exception and embed in the custom exception object the actual exception.
Re:Ask HN: What is your best advice for a junior software de... by gpderetta on Wednesday October 03, 2018 @07:14PM (#18135590)
Assert
Re:Ask HN: What is your best advice for a junior software de... by scarface74 on Wednesday October 03, 2018 @01:18PM (#18132451)
That’s only true if the developer of the class module let the entire stack trace get through to the consumer.

In C# it’s the difference between...

try

{

....

}catch(Exception e)

{

//Do stuff

   throw new MyCustomException(“Something Bad happened”);
}

And

try

{

....

}catch(Exception e)

{

  //do stuff

   throw;

}
Re:Ask HN: What is your best advice for a junior software de... by moron4hire on Wednesday October 03, 2018 @04:00PM (#18134270)
Erh, exception types should include an inner exception parameter, for the generic one they wrap. So neither of your two examples are all that great.
Re:Ask HN: What is your best advice for a junior software de... by scarface74 on Wednesday October 03, 2018 @04:43PM (#18134664)
Why would I wrap an exception if I don’t plan to have special handling? If it is exception that I didn’t throw because of a business reason, why not just throw the original exception?
Re:Ask HN: What is your best advice for a junior software de... by moron4hire on Wednesday October 03, 2018 @05:25PM (#18134952)
If you don't have any special handling, then why are you catching it at all?
Re:Ask HN: What is your best advice for a junior software de... by scarface74 on Wednesday October 03, 2018 @05:30PM (#18134987)
That was the "//Do stuff" part, you may want to do some cleanup (in C# usually handled by a finally block or a "using" block), send a custom notification, logging (usually I would just let the client handle logging), etc.
Re:Ask HN: What is your best advice for a junior software de... by debaserab2 on Wednesday October 03, 2018 @02:43PM (#18133413)
In what case would you ever want the second example?
Re:Ask HN: What is your best advice for a junior software de... by orangepenguin on Wednesday October 03, 2018 @03:39PM (#18134030)
Always. If you can't resolve the exception and continue processing normally, you should never discard the exception you caught and create a new one of your own. If you must create one of your own, include the one you caught for the additional context.

It's pretty frustrating when you're debugging someone else's code and their error handling just throws away all of the useful information and replaces it with a generic "Something broke" kind of message.

Re:Ask HN: What is your best advice for a junior software de... by elsombrero on Wednesday October 03, 2018 @03:07PM (#18133710)
usually you may catch a general exception and throw another one that's caught up the call stack. In this case i think it may be useful for logging additional causes that are not going to be obvious with just the stacktrace(?)
Re:Ask HN: What is your best advice for a junior software de... by bmhin on Wednesday October 03, 2018 @02:25PM (#18133169)
I remember once encountering an error that had all of the above plus it presented the solution to the issue right in the error message. It was amazing and why I still remember seeing that to this day.
Re:Ask HN: What is your best advice for a junior software de... by avip on Wednesday October 03, 2018 @05:12PM (#18134856)
Let's try that! I was trying to do some trivial task on a .gov website, but was greeted with the following, which I'm pasting here for your convenience. Could you spot the problem? Because their customer service can't.

  ---
Error Page Exception SRVE0260E: The server cannot use the error page specified for your application to handle the Original Exception printed below.

Original Exception: Error Message: javax.servlet.ServletException: /verification.xhtml at line 66 and column 34 action="#{verificationAction.authenticateClient()}": java.lang.NullPointerException Error Code: 500 Target Servlet: Faces Servlet Error Stack: javax.el.ELException: /verification.xhtml at line 66 and column 34 action="#{verificationAction.authenticateClient()}": java.lang.NullPointerException at org.apache.myfaces.view.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:95) at javax.faces.component._MethodExpressionToMethodBinding.invoke(_MethodExpressionToMethodBinding.java:88) at org.apache.myfaces.application.ActionListenerImpl.__AW_processAction(ActionListenerImpl.java:100) at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java) at javax.faces.component.UICommand.broadcast(UICommand.java:120) at javax.faces.component.UIViewRoot._broadcastAll(UIViewRoot.java:995) at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:278) at javax.faces.component.UIViewRoot._process(UIViewRoot.java:1307) at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:733) at org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:34) at org.apache.myfaces.lifecycle.LifecycleImpl.__AW_executePhase(LifecycleImpl.java:172) at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java) at org.apache.myfaces.lifecycle.LifecycleImpl.__AW_execute(LifecycleImpl.java:119) at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java) at javax.faces.webapp.FacesServlet.__AW_service(FacesServlet.java:189) at javax.faces.webapp.FacesServlet.service(FacesServlet.java) at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1233) at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:782) at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:481) at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178) at com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:136) at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:97) at com.icbc.licensing.filter.ThreadContextFilter.__AW_doFilter(ThreadContextFilter.java:92) at com.icbc.licensing.filter.ThreadContextFilter.doFilter(ThreadContextFilter.java) at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195) at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91) at org.apache.logging.log4j.web.Log4jServletFilter.__AW_doFilter(Log4jServletFilter.java:71) at org.apache.logging.log4j.web.Log4jServletFilter.doFilter(Log4jServletFilter.java) at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195) at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91) at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:967) at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1107) at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:87) at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:949) at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1817) at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:200) at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:463) at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:530) at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:316) at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:287) at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214) at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113) at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:175) at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217) at com.ibm.io.async.AsyncChannelFuture$1.__AW_run(AsyncChannelFuture.java:205) at com.ibm.io.async.AsyncChannelFuture$1.run(AsyncChannelFuture.java) at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1892) Caused by: java.lang.NullPointerException at com.icbc.licensing.clio.action.VerificationAction.DbAuthInsertandCount(VerificationAction.java:118) at com.icbc.licensing.clio.action.VerificationAction.__AW_authenticateClient(VerificationAction.java:161) at com.icbc.licensing.clio.action.VerificationAction.authenticateClient(VerificationAction.java) at sun.reflect.GeneratedMethodAccessor440.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:56) at java.lang.reflect.Method.invoke(Method.java:620) at org.apache.el.parser.AstValue.__AW_invoke(AstValue.java:268) at org.apache.el.parser.AstValue.invoke(AstValue.java) at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278) at org.apache.myfaces.view.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:83) ... 46 more

Error Page Exception: Error Message: javax.servlet.ServletException: WebBeans context with scope type annotation @RequestScoped does not exist within current thread Error Code: 0 Target Servlet: Error Stack: javax.enterprise.context.ContextNotActiveException: WebBeans context with scope type annotation @RequestScoped does not exist within current thread at org.apache.webbeans.container.BeanManagerImpl.__AW_getContext(BeanManagerImpl.java:363) at org.apache.webbeans.container.BeanManagerImpl.getContext(BeanManagerImpl.java) at org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.getContextualInstance(NormalScopedBeanInterceptorHandler.java:125) at org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.invoke(NormalScopedBeanInterceptorHandler.java:96) at org.apache.webbeans.conversation.ConversationImpl_$$_javassist_0.isTransient(ConversationImpl_$$_javassist_0.java) at ...

Re:Ask HN: What is your best advice for a junior software de... by s369610 on Wednesday October 03, 2018 @07:28PM (#18135673)
verifcationAction.authenticateClient() call hit a null ref exception (called from the template at /verification.xhtml) and their error page is trying to use a webBean context which hasn't been setup or activated yet to display the error.

The original site of the null ref error seems to be the DBAuthInsert method at com.icbc.licensing.clio.action.VerificationAction.DbAuthInsertandCount(VerificationAction.java:118) so maybe a getConnection is returning a null and not being checked, or some config variable is borked. Would start digging at line 118 to work out what variables are being dereferenced and where their values come from.

Re:Ask HN: What is your best advice for a junior software de... by emmelaich on Wednesday October 03, 2018 @07:24PM (#18135648)
Re:Ask HN: What is your best advice for a junior software de... by rad_gruchalski on Wednesday October 03, 2018 @07:13PM (#18135585)
The server process running in a thread other than the router? Dunno, I’m sure I could figure it out having access to the code. Support most likely does not employ software engineers / SREs.