[Javascript] Try and Catch Question

Alexander Freiria xandercoded at gmail.com
Mon Mar 2 11:27:11 CST 2009


Ah yes you are right... var foo = something

On Mon, Mar 2, 2009 at 11:25 AM, Peter Brunone <peter at brunone.com> wrote:

> Usually with a Javascript exception, you'll be looking at the message
> rather than the exception type (since technically, everything is variant in
> JS anyway).
>
> ----------------------------------------
>
> From: "Alexander Freiria" xandercoded at gmail.com
>
> I am a C# .NET developer. I know that there are different types of objects
> that are thrown... Given this, it is possible to check the type of object
> thrown and react in different ways... For the how that this is done in
> Javascript I am not too sure. An example of this would be nice.
>
> On Mon, Mar 2, 2009 at 8:51 AM, MEM wrote:
>
> > Ok... we have to have patience with me, sorry, here it goes:
> >
> > So you are saying that the (e) is there so we can identify what as being
> > thrown. Why? Because if we identify what as being thrown we can use that
> > identifier somehow, for example,
> > If "we want to ignore some errors but we want to respond to others". Is
> > this
> > assumption correct?
> >
> > The fact that we cannot have a catch() without something inside is
> because
> > we are not defining WHAT we want to catch, but that supposes that, with a
> > catch(), we can catch more than exceptions. Right?
> > But is that really important to distinguish what kind of catch are we
> > having
> > there? I mean, since the procedure is the same for no matter what is
> catch
> > by the catch function, why can't we have a simple catch(), for the cases
> > that we don't want to distinguish the exceptions? I'm sure someone have
> > thinking this before, and there is a reason why we cannot have catch()
> > alone. That's probably the main reason why I can't fully understand, in
> > some
> > cases, (because the other cases you have already told me) why oh why, we
> > need something inside the ().
> >
> >
> > Ps- I've really search on the net for this, but it seems like everybody
> > explains how to do the "try catch" thing, but they don't explain properly
> > what each part of the "try catch" really means.
> >
> >
> > Thanks a lot once again,
> > Márcio
> >
> >
> > -----Original Message-----
> > From: javascript-bounces at lists.evolt.org
> > [mailto:javascript-bounces at lists.evolt.org] On Behalf Of John Warner
> > Sent: segunda-feira, 2 de Março de 2009 12:49
> > To: 'JavaScript List'
> > Subject: Re: [Javascript] Try and Catch Question
> >
> > (e) allows your catch block to indentify the exception thrown. In some
> try
> > blocks more than one thing can go wrong, you might choose to ignore some
> > errors but want to respond to others.
> >
> > John Warner
> >
> >
> > > -----Original Message-----
> > > From: javascript-bounces at lists.evolt.org [mailto:javascript-
> > > bounces at lists.evolt.org] On Behalf Of MEM
> > > Sent: Monday, March 02, 2009 7:16 AM
> > > To: javascript at lists.evolt.org
> > > Subject: [Javascript] Try and Catch Question
> > >
> > > Hi all, this is my first post, (so if anything is not right in the way
> I
> > > post, please let me know).
> > >
> > >
> > >
> > >
> > >
> > > When we use a try catch statement like this:
> > >
> > > try {
> > >
> > >
> > >
> > > } catch (e) {
> > >
> > >
> > >
> > > }
> > >
> > >
> > >
> > > Why do we need the 'e' ?
> > >
> > >
> > >
> > > Well, I have seen also with 'err' etc, so I presume the point is to
> have
> > > only something that represents the name error. But, what for? I mean,
> > > normally in this kind of statements I never see that 'e' or 'err' being
> > used
> > > for nothing, I see no e="ups error" or something. So, what is that e
> > for?
> > >
> > >
> > >
> > >
> > >
> > > Thanks a lot,
> > >
> > > Márcio
> _______________________________________________
> Javascript mailing list
> Javascript at lists.evolt.org
> http://lists.evolt.org/mailman/listinfo/javascript
>



More information about the Javascript mailing list