Coding

Note: This article was published while I was in my early 20s. I was much younger and dumber. Please don't hold it against me. One of the perils of having a 20+ year old website!

This semester I am taking CompSci II, an advanced Java programming course at my school. So I figured I might as well live up to the name of my blog and talk about it. I am not planning on talking about CS I stuff- that is, basic programming- ifs, whiles, fors etc. unless I am asked. I’d also like you to keep in mind that I am still learning the CS II stuff, so if you see something that’s wrong or it doesn’t seem like I fully understand it, feel free to correct me in the comments.
It’s tough to kinda find a starting point for this- so I guess I can go by class. Tonight we did error handling and exceptions. There are 3 types of errors- syntax, logic, and run time. Exception handling is for run time errors, which, if the program is not coded correctly, will make the program crash. This takes away from the robustness of the program, where robustness is the property of reacting “gracefully” (as opposed to “crashing”) when abnormal conditions.
To prevent crashes, making the program more robust, we add exception handling in the form of a try/catch statement. a try/catch statement is set up like this:

try{
-code with possible bugs/errors/exceptions-
}
catch(excetionType1 name){
-how you want to handle the error-
}
catch(excetionType2 name){
-how you want to handle the error-
}
finally{
-statements executed after try and catch sections-
}

The way this is set up, you put code in the try section. If at any time in that code an error occurs (stated in Java as “An exception is thrown”) it will check the catch statements looking for that exception to see how to handle it. Usually, (in my experiences) the exception is simply handled with a print statement stating the error. In the future, I’m sure we will look into how to use exception handling not only to state the error, but also allow the program to keep going, or revert back to before the error. The finally statement will be executed whether or not an exception is thrown.
You can find a list of Java Exceptions here. Once my professor posts his notes on exception handling, I will post them here. Later

Update: Here is that link like I promised.

Similar Posts

  • |

    New Plug-in: Latest Post Redirect

    Last updated: March 5, 2021One thing I often forget to do is update social links when I’m promoting a new blog post or podcast episode. Especially on Instagram, I’ll say something like, “link in the profile,”1 only to forget to add the link to the profile! Services like Linktree help a little, but you still…

  • | |

    Directory Handler at Theme Forest

    Note: This article was published while I was in my early 20s. I was much younger and dumber. Please don’t hold it against me. One of the perils of having a 20+ year old website!I’m happy to announce my first Theme Forest component, Directory Handler. it’s a simple set of 2 classes that handle (in…

  • |

    Add Attachments to WordPress Search Results

    I feel like this has to have been done a lot, and there are great plugins out there for it, but if you’re just looking to add a quick function to your theme (or a really simple plugin) yourself, here’s how to modify WordPress’ search query to include attachments (like images). function attachment_search( $query ) {…

  • Fixing the Fatal ‘add_rewrite_tag()’ Error

    I’m working on a WordPress little side project where I am registering a new Custom Post Type and Taxonomy and came across this: Fatal error: Call to a member function add_rewrite_tag() on a non-object… After doing a Google Search to try to figure out what the issue is, all I came up with was “disable…

  • | |

    My First NETTUTS Tut

    Note: This article was published while I was in my early 20s. I was much younger and dumber. Please don’t hold it against me. One of the perils of having a 20+ year old website!Web Design tutorial blog NETTUTS published an article I wrote about Building a Facebook Appication Check it out! New post here…

  • Wow….

    Note: This article was published while I was in my early 20s. I was much younger and dumber. Please don’t hold it against me. One of the perils of having a 20+ year old website!So Joe, what did you do today? “O you know, the usual. Spur of the moment trip to Hershey Park, Texas…

One Comment

Comments are closed.