Can I throw an error in vbscript?

前端 未结 3 2028
野趣味
野趣味 2020-12-29 02:53

I\'m used to programing in C#, which obviously has some pretty robust error handling. Now I\'m working on a short project in VBScript. I\'ve read about the error handling wi

3条回答
  •  無奈伤痛
    2020-12-29 03:37

    C# try-catch-finally

    try {
        // some code
    } catch( Exception e ) {
        // error handler
    } finally {
        // clean up things
    }
    

    VBScript equivalent

    on error resume next
    ' some code
    if( Err.number <> 0 ) then
        ' error handler -- you can use Err.raise() here to display your own errors
        Err.clear()
    else
        ' clean up things
    end if
    on error goto 0
    

    For good VBScript examples, you could check the ASP Xtreme Evolution project

提交回复
热议问题