Exception Handling
-
Hi, One of my webmethods throw an exception: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Data.SqlClient.SqlException: The provided Supervisor emailID either invalid or do not exists in the database at ManageEmployeeServices.AddEmployee(Int64 EmpID, String EmpName, String EmpEmailID, String SupervisorEmailID, String LocationName) in c:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\WebSites\ManageEmployeeServices\App_Code\ManageEmployeeServices.cs:line 53 --- End of inner exception stack trace --- And In my client I want to display only the bolded text as it is the actual error message. So how can I trunctate all the unwanted string from the error message? Thanks:
Rakesh
-
Hi, One of my webmethods throw an exception: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Data.SqlClient.SqlException: The provided Supervisor emailID either invalid or do not exists in the database at ManageEmployeeServices.AddEmployee(Int64 EmpID, String EmpName, String EmpEmailID, String SupervisorEmailID, String LocationName) in c:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\WebSites\ManageEmployeeServices\App_Code\ManageEmployeeServices.cs:line 53 --- End of inner exception stack trace --- And In my client I want to display only the bolded text as it is the actual error message. So how can I trunctate all the unwanted string from the error message? Thanks:
Rakesh
Try this? [WebMethod] string MethodName { try { ..Your Code return ""; } catch (SqlException ex) { return ex.Message; } } So in the event of an error, your method will return the error message, otherwise returns an empty string, or null if you prefer?
-
Try this? [WebMethod] string MethodName { try { ..Your Code return ""; } catch (SqlException ex) { return ex.Message; } } So in the event of an error, your method will return the error message, otherwise returns an empty string, or null if you prefer?
-
hi, My intention is to return a dataset from the web method so how can I mention the return type as string? Regards,
Rakesh
You can declare the dataset outside of the Try block, and in the event of an error, add an Errors Table too it that contains all of the info. Then check for the existance of that table on the return trip.
-
You can declare the dataset outside of the Try block, and in the event of an error, add an Errors Table too it that contains all of the info. Then check for the existance of that table on the return trip.