Instruction throw is making the system inconsistent

Asked

Viewed 86 times

1

I have a Try.. catch and catch the fellow who did let only throw.

catch(){throw;}

Well, my intention is to treat all that exceptions and not just let throw. But since I just got here at the company, I’ve already arrived and have to solve problems and encode new features. Turns out, I discovered today that in the production environment simply leave the throw as it is, it kicks off the system with different unexpected behaviors. Well, the answer is to treat the throw. What I would like to know what happens to the throw in order to give this type of error in certain environment and others do not. The production environment our user accesses via portal, because they are in several places(states) of the country. In the Desenv or Homol environment, the mounted system access url is very simple, like: localhost:porta/Default.aspx, in homol we have something like: brcohmlg:porta/Default.aspx, now in production no. A url mounted is quite complex, much bigger than this and I don’t know if this has anything to do.

  • 3

    I’ve been talking about this for a while here. Many people do not understand that exceptions are complicated, you can not use them without completely mastering the subject. http://answall.com/a/30168/101. In this case use a throw alone doesn’t make any sense. And this shows that the programmer didn’t know what he was doing. The problem is probably not even in this part. As you do not know the system well it will not be easy to find everywhere where cause problem. If you need more specific help, you will have to give a lot more details. And I don’t even know if it would fit here everything that is needed.

1 answer

8

Use of the instruction throw alone inside the block catch() causes the captured exception to be re-launched, has the same effect as there was no block try/catch

If there is any inconsistency in the behaviour of the system, I think it has nothing to do with the throw by itself, but with the kind of error that is being captured/released.

  • 1

    Just to complement... the instruction throw is valid because you can do more things on catch in addition to relaunching the same exception. For example, if there was an error and you are on the catch, you can do a rollback of your method operation and pass the exception to the next context below on the runstack. Very useful. But throw alone inside the catch is really bad thing. That’s uglier than hitting your own mother.

  • "That’s uglier than hitting your own mother." ahahah @Renan

  • I understood here why the throw is alone. It’s when the page comes from the designer, they all come like this with the throw and then receive treatment. The fellow designer here sends everything as a throw because he doesn’t know what to do. It’s up to us developers to handle. As the guy who was here before left a lot like this, I’ve been picking up some problems and suspicious of the throw, so my post.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.