Click here to Skip to main content
15,886,110 members
Home / Discussions / C#
   

C#

 
GeneralRe: OleDb Error Pin
Kevin Marois15-Jan-20 10:57
professionalKevin Marois15-Jan-20 10:57 
GeneralRe: OleDb Error [UPDATED] Pin
Dave Kreskowiak15-Jan-20 9:45
mveDave Kreskowiak15-Jan-20 9:45 
GeneralRe: OleDb Error [UPDATED] Pin
Kevin Marois15-Jan-20 10:51
professionalKevin Marois15-Jan-20 10:51 
GeneralRe: OleDb Error [UPDATED] Pin
Eddy Vluggen15-Jan-20 12:15
professionalEddy Vluggen15-Jan-20 12:15 
GeneralRe: OleDb Error [UPDATED] Pin
Dave Kreskowiak15-Jan-20 12:50
mveDave Kreskowiak15-Jan-20 12:50 
GeneralRe: OleDb Error [UPDATED] Pin
Eddy Vluggen15-Jan-20 12:57
professionalEddy Vluggen15-Jan-20 12:57 
QuestionException Handling Question Pin
Kevin Marois14-Jan-20 18:53
professionalKevin Marois14-Jan-20 18:53 
AnswerRe: Exception Handling Question Pin
OriginalGriff14-Jan-20 21:19
mveOriginalGriff14-Jan-20 21:19 
Don't throw a "global exception", throw an Application Exception
throw new ApplicationException($"The role '{role.RoleName}' cannot be deleted because it has users assigned to it." );

You can then catch just those and report them:
C#
catch (ApplicationException aex)
   {
   MessageBox.Show(aex.Message);
   return;
   }
catch (Exception ex)
   {
   ...
Or better, don't throw an exception if your code is going to handle it in the same method - report the problem directly in your code instead, and return from the method.
Exceptions shouldn't be used as a form of flow control!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!

AnswerRe: Exception Handling Question Pin
F-ES Sitecore14-Jan-20 22:49
professionalF-ES Sitecore14-Jan-20 22:49 
SuggestionRe: Exception Handling Question Pin
Richard Deeming15-Jan-20 0:38
mveRichard Deeming15-Jan-20 0:38 
AnswerRe: Exception Handling Question Pin
Gerry Schmitz15-Jan-20 13:44
mveGerry Schmitz15-Jan-20 13:44 
QuestionHow to add text to a script tag at src using jQuery Pin
Member 1316600712-Jan-20 7:52
Member 1316600712-Jan-20 7:52 
AnswerRe: How to add text to a script tag at src using jQuery Pin
OriginalGriff12-Jan-20 10:25
mveOriginalGriff12-Jan-20 10:25 
Questioni need a c# project using interfaces about anything Pin
Ali Al Akbar Hachem12-Jan-20 4:23
Ali Al Akbar Hachem12-Jan-20 4:23 
AnswerRe: i need a c# project using interfaces about anything Pin
OriginalGriff12-Jan-20 4:25
mveOriginalGriff12-Jan-20 4:25 
AnswerRe: i need a c# project using interfaces about anything Pin
Luc Pattyn13-Jan-20 1:03
sitebuilderLuc Pattyn13-Jan-20 1:03 
QuestionAccess winforms application when user right click on a file Pin
Hero201812-Jan-20 1:54
Hero201812-Jan-20 1:54 
AnswerRe: Access winforms application when user right click on a file Pin
OriginalGriff12-Jan-20 2:20
mveOriginalGriff12-Jan-20 2:20 
GeneralRe: Access winforms application when user right click on a file Pin
Hero201812-Jan-20 9:48
Hero201812-Jan-20 9:48 
GeneralRe: Access winforms application when user right click on a file Pin
OriginalGriff12-Jan-20 10:23
mveOriginalGriff12-Jan-20 10:23 
GeneralRe: Access winforms application when user right click on a file Pin
Hero201812-Jan-20 12:22
Hero201812-Jan-20 12:22 
GeneralRe: Access winforms application when user right click on a file Pin
OriginalGriff12-Jan-20 22:07
mveOriginalGriff12-Jan-20 22:07 
QuestionHtmlAgilityPack - How to get the Value from the tag <div> into aspx.cs Pin
Member 1316600710-Jan-20 6:02
Member 1316600710-Jan-20 6:02 
AnswerRe: HtmlAgilityPack - How to get the Value from the tag <div> into aspx.cs Pin
Richard Deeming10-Jan-20 6:10
mveRichard Deeming10-Jan-20 6:10 
Questionhow to configure LED8 customer pole display? Pin
Member 122427179-Jan-20 22:13
Member 122427179-Jan-20 22:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.