Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It looks like you don't really know what to do with the exception in <code>getUserInfo</code> and just want to pass it on to the outer function.</p> <p>Well, here's the great thing about exceptions: <em>They are passed on automatically!</em> There's nothing you need to do, and, in particular, you do not need to use the return value of the function for that. Just don't catch the exception <em>until you know what to do with it</em>.</p> <hr> <p>For example, in your case, just handle the error in the <em>calling</em> function instead:</p> <ul> <li><p>Remove the error handling code from the called function:</p> <pre><code>Public Function getUserInfo(ByValue testUserIdAs String) As DataSet Dim objTestWs As New TestWebService.UserMaintenanceSoapClient Return objTestWs.dsGetUserInfo(TestOU, PAC, paramUserID) End Function </code></pre></li> <li><p>and add it to the calling function, i.e., replace</p> <pre><code>... Dim dsUserInfo As DataSet dsUserInfo = getUserInfo() ... </code></pre> <p>with</p> <pre><code>... Dim dsUserInfo As DataSet Try dsUserInfo = getUserInfo() Catch ex As Exception ' Do whatever you want to do in case of an error here MsgBox("Could not get User Info: " &amp; ex.Message) Return End Try ... </code></pre></li> </ul> <hr> <p>One you are familiar with this technique, you can go on to more advanced topics like throwing your own exception, like @Justin suggested. Just make sure to include information about the <em>original cause of the error</em> in your own exception, for example, by copying parts of <code>ex.Message</code> into your own exception message and setting the <code>innerException</code> property.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload