Handling exceptions
Your application will need to handle both Mashup Service-specific exceptions and general exceptions.
- C# example
catch (System.Web.Services.Protocols.SoapException ex) { if (ex.Detail != null) { if (ex.Detail.FirstChild.LocalName == "CCSPromptFault") { System.Console.WriteLine(ex.ToString()); return "Please make sure the report ID is correct ..."; } else if (ex.Detail.FirstChild.LocalName == "CCSAuthenticationFault") { System.Console.WriteLine(ex.ToString()); return "Login Failed. Please try again."; } else if (ex.Detail.FirstChild.LocalName == "CCSGeneralFault") { System.Console.WriteLine(ex.ToString()); return "Please make sure the report ID is correct ..."; } else { return (ex.Message); } } else { System.Console.WriteLine("ERROR: " + ex.Message); return (ex.Message); } }
- Java™ example
catch (CCSGeneralFault e) { e.printStackTrace(); return "Please make sure the report ID is correct ..."; } catch (CCSPromptFault e) { e.printStackTrace(); return "Please make sure the report ID is correct ..."; } catch (CCSAuthenticationFault e) { e.printStackTrace(); return "Login Failed. Please try again."; } catch (RemoteException e) { e.getMessage(); return e.getMessage(); } catch (ServiceException e) { e.printStackTrace(); return e.getMessage(); } catch (Exception e) { e.printStackTrace(); }