Results 1 to 11 of 11

Thread: Try...Catch block "pauses" while debugging

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2010
    Posts
    72

    Try...Catch block "pauses" while debugging

    Hello,
    I have a database application with error handling in a separate module.

    vb Code:
    1. ...
    2. ' EDIT A RECORD
    3. With currentCustomer
    4.   .Address = txtAddress.Text
    5.   .ContactDate = dtpContactDate.Value
    6.   'etc...
    7. End With
    8.  
    9. ' SAVE
    10. Try
    11.   Db.SubmitChanges()
    12.   Me.Close()
    13. Catch ex As Exception
    14.   MessageBox.Show(ex.Message)
    15. End Try

    I have defined validation code in a partial class:

    vb Code:
    1. Partial Public Class Customer
    2.  
    3. Private Sub OnValidate(ByVal action As System.Data.Linq.ChangeAction)
    4.   Select Case action
    5.   Case ChangeAction.Update
    6.     If Me.Address = Nothing Then
    7.       Throw New Exception("Fill the Address!")
    8.     End If
    9. 'etc...

    But while debugging (and "Address" field is left empty), the program breaks and I get an exception at the "Throw New Exception" line even if the error should be trapped by the "Try...Catch" block.
    At runtime, everything works well and the correct error is displayed.

    What is happening?
    Last edited by axplains; Feb 8th, 2010 at 10:10 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width