Post: [C#] - Building up an error list!
12-30-2011, 06:07 PM #1
Correy
I'm the Original
(adsbygoogle = window.adsbygoogle || []).push({}); this is pretty basic but it's very useful..
it basically builds up a full custom error list, without defining every message box.

so you want to create a new void, or on a button.. whatever you like.
start of with this..
    
private void CheckErrors()
{
string Errors = null;
}


this means that at the start 'Errors' wont be defined, basically reset so it can be built again.
now you want to add your custom errors, so something like this..
    
private void CheckErrors()
{
string Errors = null;
if( textBox1.Text == "" )
{
Errors += "- No Text Inputted!\n";
}
}


make sure you have 'Errors +=', this means it adding to it.. also the '\n' is for a new line after, so it's shown clearer.
Now, you want to do it for everything you want to error.

After stating all the errors you create a part in the void which acts on either if it's Errored or no errors, just like this..
    
private void CheckErrors()
{
string Errors = null;
if( textBox1.Text == "" )
{
Errors += "- No Text Inputted!\n";
}

if( Errors == null )
{
//YOUR FINAL FUNCTION
}
else
{
MessageBox.Show( "The Following Errors Occured\n" + Errors );
}
}


and thats bascially it, it will give you a full list instead of threading ever error and making a new message box show for each error.
People will already have something like this, but if you dont.. then be sure to use it.

The following 2 users say thank you to Correy for this useful post:

tokzikate, xVz
01-01-2012, 12:54 PM #2
Correy
I'm the Original
Originally posted by reScript
I wouldn't let my program error personally, I would throw the exception of any script that may not work because of a file error or bad user input.
I would understand a log though, sometimes I use one while making something so I know what's working and what is not. :p


just shit :whistle:
01-01-2012, 01:16 PM #3
Correy
I'm the Original
Originally posted by reScript
What's just shit? O.o


my error builder lol, it just a simple way :p

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo