G
Guest
I have an application that has a presentation later, business layer, and
data layer. All three projects have their own exception policy, the "UI
Policy", "BL Policy", "DL Policy", all of which will log the error in the
application event logs. When a database error occurs such as a missing
stored procedure, all three policies will log the event resulting in three
different entries in the error. My boss says there is a way in the
exception handling to turn these duplicate errors off, but I certainly can't
find a way to do this. And logically these are not duplicate errors, they
each use different policies and they each have a different stack recorded.
Every single procedure in every project has the exception code as follows:
Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex,
"UI Exception Policy")
If rethrow Then
throw
End If
Until ultimately it gets back to the calling procedure, which also logs the
event, so we could have 5 million entries for one error. Okay, slight
exaggeration.
My thought is we need to be more precise on how we handle these errors. The
data layer is always bubbled up, so I wouldn't think we'd need the data
layer errors, since the ui layer will. What is the proper way to do this?
Some example code:
Presentation Layer:
Sub TestDatabaseConnection
try
Dim bl as new bl
Dim ds as new Dataset
ds = bl.UpdateData(connString, spUpdateStuff)
Catch ex as exception
Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex,
"UI Exception Policy")
If rethrow Then
throw
End If
end try
end sub
Business Layer (bl)
function UpdateData(connString, sp) as integer
Dim dl as new dl
return dl.ExecuteNonquery(connString, sp)
Catch ex as exception
Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex,
"BL Exception Policy")
If rethrow Then
throw
End If
end try
end function
Data Layer (dl)
function ExecuteNonQuery(connString, sp) as integer
try
Dim retval as integer
retval = SqlDataAccess.ExecuteNonQuery(connString,
commandtype.storedprocedure, sp)
return retval
Catch ex as exception
Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex,
"DL Exception Policy")
If rethrow Then
throw
End If
end try
end fundtion
data layer. All three projects have their own exception policy, the "UI
Policy", "BL Policy", "DL Policy", all of which will log the error in the
application event logs. When a database error occurs such as a missing
stored procedure, all three policies will log the event resulting in three
different entries in the error. My boss says there is a way in the
exception handling to turn these duplicate errors off, but I certainly can't
find a way to do this. And logically these are not duplicate errors, they
each use different policies and they each have a different stack recorded.
Every single procedure in every project has the exception code as follows:
Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex,
"UI Exception Policy")
If rethrow Then
throw
End If
Until ultimately it gets back to the calling procedure, which also logs the
event, so we could have 5 million entries for one error. Okay, slight
exaggeration.
My thought is we need to be more precise on how we handle these errors. The
data layer is always bubbled up, so I wouldn't think we'd need the data
layer errors, since the ui layer will. What is the proper way to do this?
Some example code:
Presentation Layer:
Sub TestDatabaseConnection
try
Dim bl as new bl
Dim ds as new Dataset
ds = bl.UpdateData(connString, spUpdateStuff)
Catch ex as exception
Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex,
"UI Exception Policy")
If rethrow Then
throw
End If
end try
end sub
Business Layer (bl)
function UpdateData(connString, sp) as integer
Dim dl as new dl
return dl.ExecuteNonquery(connString, sp)
Catch ex as exception
Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex,
"BL Exception Policy")
If rethrow Then
throw
End If
end try
end function
Data Layer (dl)
function ExecuteNonQuery(connString, sp) as integer
try
Dim retval as integer
retval = SqlDataAccess.ExecuteNonQuery(connString,
commandtype.storedprocedure, sp)
return retval
Catch ex as exception
Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex,
"DL Exception Policy")
If rethrow Then
throw
End If
end try
end fundtion