The Post Your Thoughts of the Moment Thread 2

Started by Harvest, February 22, 2008, 12:40:22 PM

Previous topic - Next topic

The Deku Trombonist

#8775
Quote from: Offkey on June 23, 2010, 08:26:37 AMUhm a bit, well not really C++ but I'm sort of experienced with C#/Java, done a bit in C as well. You mean you just want to use a try-catch block? Put the code that may throw the error within a try { (...) } block, follow it with catch (Exception e) { (...) } where you put the handling for the error within the catch block. I'm not 100% sure if I used the right syntax for the "Exception e" part though.
It's the "catch(Exception e)" part that keeps returning a syntax error.

Fixed it now.
EDIT: Is there a way to test for what the exception is?

Offkey

Yeah, you can put multiple catch-blocks in succession, then specify the exception type between the parentheses, for example catch (IOException e) {} catch (NullReferenceException) {} and so on.
The flow of time is always cruel... its speed seems different for each person, but no one can change it... A thing that does not change with time is a memory of younger days...

Youtube channel.
Video's coming soon(ish).

The Deku Trombonist

If the action for the "default:" value of a case statement, is  - throw "insertsomethinghere"; how do I catch one of those?

Offkey

Uhm, for throwing errors, usually something like "throw new Exception()" is used right? You can then just catch the type of Exception specified there, in this case its just a general one but it can be specific as well.
The flow of time is always cruel... its speed seems different for each person, but no one can change it... A thing that does not change with time is a memory of younger days...

Youtube channel.
Video's coming soon(ish).

The Deku Trombonist


Offkey

The flow of time is always cruel... its speed seems different for each person, but no one can change it... A thing that does not change with time is a memory of younger days...

Youtube channel.
Video's coming soon(ish).

Brassman388

So work has pretty much consumed most of my time. Won't be doing much later on in the week.

Don't worry, UGC, I'll have the stuff ready by this weekend as promised.

MaestroUGC

Try to do everything; you're bound to succeed with at least one.

KefkaticFanatic

Quote from: DekuTrombonist on June 23, 2010, 01:37:49 PMIt's the "catch(Exception e)" part that keeps returning a syntax error.

Fixed it now.
EDIT: Is there a way to test for what the exception is?

In the catch block do "System.outPrintLn(e.toString)" or whatever the print is.  There is something better than just printing to a String, but I forget.



me irl
[close]

Offkey

You mean e.printStackTrace()? That way you get a bit more info about why the error was thrown.
The flow of time is always cruel... its speed seems different for each person, but no one can change it... A thing that does not change with time is a memory of younger days...

Youtube channel.
Video's coming soon(ish).

universe-X

Hey, does anyone know which 3 songs from SMG Koji Kondo did? I remember hearing Koji did 3, Mahito Yokota (is it?) did the rest.

Also, unrelated, has anyone seen Maretocks lately? :P

KefkaticFanatic

Quote from: Offkey on June 23, 2010, 03:30:52 PMYou mean e.printStackTrace()? That way you get a bit more info about why the error was thrown.
Yea that's what I was thinking of.  Just print that out.  Or whatever you named the exception.



me irl
[close]

Taser9090

Right now, outside, everything is pure yellow. That never happens.

"They say money makes the world go 'round. And what goes around, comes around" ~Rover

TheLegend

where do you live
EDIT: TASER I FINISHED MY FIRST ARRANGEMENT FOR YOU

Harvest

I'm going to see Star Wars in concert this July.

:|  epic.
-