Hi,
I wrote a program where I get a debug assertion failure. I've made it so that if I press ignore, execution continues correctly. The only thing is I don't want to keep pressing ignore, is there a way to make it ignore automatically? Without the message box appearing?

I doubt the code will be of any use to you, but here it is. The assertion failure occurs in the try part, then I press ignore, and it goes to the catch.

while( std::getline(boxFiles, discardLetters, ' ') )
{
	try
	{
	std::getline(boxFiles, boxCoordinates, '\n');
	
	if (i >= 1)
	{
		while (charsInImage[i] != '|' && charsInImage[i] != '\"')
		{
			i--;
		}
		savePosition = i;
		i++;
		if (charsInImage[i] != '?')
		{
           while(charsInImage[i] != '|')
		   {
			outFile << charsInImage[i];
			i++;
		   }
		}
	}
		if (charsInImage[i] != '?')
		{
		outFile<< " " << boxCoordinates <<endl;
		}
		i = savePosition - 1;
	}


catch (...)
{
	fprintf(logFP, tmpFullFileName);
	break;
}
}

I know this is probably something I should be able to find online easily, but I guess I've been searching for the wrong thing, cuz I've got nothing. Thanks in advance!

>is there a way to make it ignore automatically? Without the message box appearing?
Yes, fix the error that causes the message in the first place. Silencing an error doesn't make the error go away, it just makes it harder to fix when ignoring it really breaks something.

No see it's ok if it's ignored. I only included a portion of the program, but the purpose of the whole thing is to read from a csv file, and fill things from the csv file into a number of txt files. The things in the csv file are supposed to have a certain format that corresponds to items in the txt files. The problem is that the csv file is huge, and contains a few mistakes. I don't want the program to stop working because of an error that will only affect one txt file and not the others. You may have noticed the "fprintf(logFP, tmpFullFileName);" line in the catch. That makes note of the error in the csv file so that I can fix it later. But the fact is, the txt files are independent of each other, and thus errors that occur in one don't affect the others.

Any ideas for an automatic ignore?

>No see it's ok if it's ignored.
No, see it's not. A debug assertion doesn't mean you hit an expected runtime error condition, and it doesn't mean that your files aren't formatted the way your program expects. It means your code is fucking wrong! Programmers put assertions into code so that they can debug impossible conditions that break invariants. If you didn't place the assertion, it means you're getting it from one of the libraries you use. Ignoring that error is not okay.

>Any ideas for an automatic ignore?
Sorry, I don't help programmers do stupid things. I teach them to do smart things.

Whoa take a deep breath! That is what's causing the assertion failure. Do you know how I know that? Because once I press ignore, check the log file, see the record where the problem occurred, and fix the format, then I don't have a problem anymore.

I'm not saying I'm using a great technique though, so I'm going to explain exactly what's happening, and maybe you can teach me a better way.
Each record in the csv file looks something like this:
ae07.txt, abs, "aaA|baB|seE|", 9

The text file looks something like this:
kjf 34 33 22 50
hg 55 44 33 22
by 10 11 12 1

The program is supposed to replace characters in the txt file so it looks like this:
seE 34 33 22 50
baB 55 44 33 22
aaA 10 11 12 1

The assertion failure occurs when "aaA|baB|seE|" has something missing in it, for example if it is "aaA|baB" which causes the i to go out of bounds.

>Because once I press ignore, check the log file, see the record
>where the problem occurred, and fix the format, then I don't have a problem anymore.

Then you're parsing the file incorrectly. The issue still remains that your code is broken and needs to be fixed.

>which causes the i to go out of bounds.
Um, did it never occur to you to check the value of i before using it?

I honestly can't articulate how utterly retarded your solution to the problem is. Especially since you know exactly where the error is coming from and can reproduce it consistently. I can only hope you're not a professional working on wall street, in the medical field, or any other area where stupid programmers mean destroyed/lost lives.

commented: ****applause*** +17

And why are you using "fprintf" and char-arrays in C++ code? This is the root of all your evil. Use std::strings instead.

Narue, WHY are you ranting about it? No I'm not a professional... It's just a question, get over it and get over yourself!

>Narue, WHY are you ranting about it?
Because I'm trying to help you, and I think ranting is the only way you'll pay attention. You should be flattered. Normally, I wouldn't bother replying to someone so stubbornly clinging to an idiotic solution.

>No I'm not a professional...
Thank God.

>It's just a question, get over it and get over yourself!
As you wish. Don't expect me to help you in the future. You can learn the hard way, for all I care.

First, one does not tell Narue to 'get over herself'. Narue knows what she is doing.

Two, if you want to write shoddy code that ignores problems and processes a CSV file, just go learn perl voluntarily and label yourself as someone who likes bad solutions to simple problems, rather than properly implemented ones.

Dropping data is bad, and you should learn what an exception is and how it works before you start yelling at other people to do bad design for you.

Twerp.

Because I'm trying to help you, and I think ranting is the only way you'll pay attention.

I really can't see why you'd think that. Obviously I'm asking the question to get ideas from other people, and I'm going to read your answers whether or not it's a rant. I wasn't clinging to my solution at all, I was trying to explain it because between your ranting and swearing I had no idea what you expected from me. I wanted your help, and I took your advice and I appreciate it. And I see that my solution was stupid, but bashing me served absolutely no purpose besides putting me in a bad mood. If that was your aim, good for you! But as far as I can tell, it wasn't, so I still can't see why you would do it.

EDIT: Toba seems to think I was "yelling" at you to do shoddy design for me, sorry if it came off that way, I wasn't.

>I really can't see why you'd think that.
All I can do is explain myself. If you still don't understand, that's not really my problem.

>I wasn't clinging to my solution at all
That's BS. Twice you tried to justify to me why you knew that it was okay to do what you wanted, even after I explained why what you wanted was the height of stupidity.

>I was trying to explain it because between your ranting and
>swearing I had no idea what you expected from me.

My first post contained no ranting and no swearing. It was a simple recommendation that you fix the problem rather than hide it. Was that too complicated for you?

>And I see that my solution was stupid
Well, it's about time.

>but bashing me served absolutely no purpose besides putting me in a bad mood
I have no interest at all in your mood. However, if "bashing" you got you to realize that your solution was stupid and do the right thing, I'd consider it a success.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.