|
This kind of error reporting is simple and clean, well suited for the developer.
Usually the user expects a more friendly approach, like a text message, anyway I suggest you to always report the error number together with such message.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
CPallini wrote: This kind of error reporting is simple and clean, well suited for the developer.
Yes it is. All the time I use it and depend on that, and try to corrected errors as much possible.
CPallini wrote: Usually the user expects a more friendly approach, like a text message
That is why I really looking for it. I found on MSDN FormatMessage function used in Windows. But seems it is more complicated at the time for me. I'll try to figure it out.
CPallini wrote: I suggest you to always report the error number together with such message.
Ok, actually there is only a word "Error" depend on the code I change it, "Error in opening file." or something like that.
I appreciate your help all the time...
Eranga
|
|
|
|
|
Eranga Thennakoon wrote: That is why I really looking for it. I found on MSDN FormatMessage function used in Windows. But seems it is more complicated at the time for me
You're right. Luckily enough, they give sample code using it.
http://msdn2.microsoft.com/en-us/library/ms680582(VS.85).aspx[^]
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
Yep....
I appreciate your help all the time...
Eranga
|
|
|
|
|
Eranga Thennakoon wrote: But seems it is more complicated...
What's complicated about calling one function to retrieve a message?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Well, to his (and mine) justification, I have to say FormatMessage hasn't the most appealing prototype I ever seen.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
Eranga Thennakoon wrote: Displaying error codes is not prefer for users.
According to me users are most probably not bothered about exact the reason behind the error. So what I used to do was telling the user about failure happened in simple sentence and add some message that is helpful for the developer.
For example, see this error message.
Fatal Error<br />
Error: Could not load the image file.<br />
Failed to load the image in CMainWindow::InitInstance.
What I noted that, user who is getting the error will inform the developer (ofcourse not directly) that the program ceased to work and shows a message as ...
So the developer got a chance to identify the problem while sitting in his seat.
PS: This may not be feasible for large scale productions. But for small scale of productions I have found it is useful.
|
|
|
|
|
That is right. Most of the time users are not worried about the error message, only looking available options like Retry, Abort, Cancel etc...
I appreciate your help all the time...
Eranga
|
|
|
|
|
Eranga Thennakoon wrote: only looking available options like Retry, Abort, Cancel etc...
|
|
|
|
|
I would suggest displaying both the error code and the error description for a couple of reasons. First, IME, numeric error codes are likely to be read back to a support person correctly as opposed to a possibly long error message text. Some users find it insulting when you have to keep asking them to "read back the error message exactly as shown," and even then may skip a word or paraphrase.
Second, if being used on a non-English version of Windows, the error message text may be unfamiliar to your support staff, but the error code will remain the same.
I tend to format errors as follows: [ActionAndOrContext]:[ErrorCode]-[ErrorMessage] . Examples:
Unable to open the data file: 5-Access is denied.
Unable to process the data file: 8-Not enough storage is available to process this command. If you are writing a Windows GUI application (using MFC or not), I would suggest using Message Boxes.
Lastly - do not forget (Correct) logging. Having an accurate log of what took place before an error is invaluable.
Peace!
-=- James Please rate this message - let me know if I helped or not!<hr></hr> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Ok thanks a lot.
I appreciate your help all the time...
Eranga
|
|
|
|
|
Hello everyone,
What is wrong with the code, I just want to allocate an array of 100 void* pointers.
int main()
{
void** p;
p = new (void*) [100];
return 0;
}
d:\visual studio 2008\projects\test_void1\test_void1\main.cpp(5) : error C2143: syntax error : missing ';' before '['
d:\visual studio 2008\projects\test_void1\test_void1\main.cpp(5) : error C3409: empty attribute block is not allowed
d:\visual studio 2008\projects\test_void1\test_void1\main.cpp(5) : error C2143: syntax error : missing ']' before 'constant'
d:\visual studio 2008\projects\test_void1\test_void1\main.cpp(5) : error C2143: syntax error : missing ';' before 'constant'
d:\visual studio 2008\projects\test_void1\test_void1\main.cpp(5) : error C2143: syntax error : missing ';' before ']'
d:\visual studio 2008\projects\test_void1\test_void1\main.cpp(5) : error C2143: syntax error : missing ';' before ']'
thanks in advance,
George
|
|
|
|
|
Just remove the paranthesis.
|
|
|
|
|
Thanks Cedric,
Your solution works! Why adding an additional () will block compiler?
regards,
George
|
|
|
|
|
George_George wrote: Why adding an additional () will block compiler?
The bigger question is, why would you think they'd be necessary?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi DavidCrow,
I want to allocate 100 void* type, so I add () besides void*, it is natural thinking, right?
regards,
George
|
|
|
|
|
George_George wrote: it is natural thinking, right?
How would you allocate 100 ints or chars?
int *n = new int[100];
int *c = new char[100]; Why would void* be any different?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi DavidCrow,
The same for int*. Here is my code,
int main()
{
int** p;
p = new (int*) [100];
delete[] p;
return 0;
}
regards,
George
|
|
|
|
|
George_George wrote: p = new (int*) [100];
You've already been told this will not work. Why do you continue to suggest it should?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Your sample also breaks if you add () between int.
My code,
int main()
{
int* p;
p = new (int) [100];
delete[] p;
return 0;
}
will get the same compile errors as I posted in the beginning of this question. Any ideas?
regards,
George
|
|
|
|
|
George_George wrote: Your sample also breaks if you add () between int.
This should come as no surprise since it would therefore be a syntax error.
Are you being thick-headed on purpose? You've already been told (more than once) that parenthesis are not allowed around the type.
int *p = new int[100];
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thanks DavidCrow,
I just recite this rule. Well...
I am just curious how compiler will interpret this statement if I add (), and why if I add (), there are so many strange errors. Just personal curious how compiler treat this than simply recite this rule.
regards,
George
|
|
|
|
|
George_George wrote: I am just curious how compiler will interpret this statement if I add ()...
Once the compiler encountered the left bracket, it complained. That should have been enough to lead you to what was wrong.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thanks for your patience, DavidCrow!
My question is answered.
regards,
George
|
|
|
|
|
The syntax you are using with the parens is how you call placement new , and the way you would be calling placement new is incorrect.
Peace!
-=- James Please rate this message - let me know if I helped or not!<hr></hr> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|