954,518 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

errors make me close program

Hey guys, i got this program im making. It encrypts and decrypts files. The problem is that whenever an error occurs while encrypting or decrypting ( having put a read-only file, a running program, input wrong keys, enter wrong encryption type...) the program tells me that an error occured. Thats nice and everything but i have to close the program, restart it and then try again. I can't just correct the mistake. If i do correct the mistake and try again, i get an error message again.

Basically i want to be able to correct mistakes without having to restart program. Does anyone know what to do?

It'll be great if someone can. Thanks in advance!

crypter
Light Poster
37 posts since Jul 2004
Reputation Points: 10
Solved Threads: 0
 

To summarize, you want to know how to write a robust program. Unfortunately, that's an art that takes experience and practice. There aren't really any tricks to it. Just know what errors could possibly happen and write code to handle them gracefully (such as with try..catch blocks).

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

obviously everyone would want to create a perfect program, but you know it doesnt always work out to plan. ok concerning the try...catch blocks, i already got that. Whenever an error occurs in the process, it tells me! thats fine and great! BUT, if i try to do the process again, it gives an automatic error, even though the information it wants is correct! I have to close the program to be able to make it work.
i was wondering if there was some sort of code that involves a "dispose" code for an open file. I would like ti put that in the catch block

crypter
Light Poster
37 posts since Jul 2004
Reputation Points: 10
Solved Threads: 0
 

Just because it tells you there's an error doesn't mean your using try/catch block correctly. It will tell you there is an error even if you have any try/catch blocks. You need to try to handle the error in the try catch block.

From what you described, you need to reset the variables you're using inside the try/catch blocks or reset them when the encrypting is done (i.e. in a finally block). I'm like 99.99% sure that's what your problem is.

Iron_Cross
Junior Poster
117 posts since Jul 2003
Reputation Points: 46
Solved Threads: 2
 

i dont think you understand... i programmed it to tell me there is an error. But i don't know, like you say, handle the error.

would you know some sort of reset code?

crypter
Light Poster
37 posts since Jul 2004
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You