Share via


PSClientError class

Contains information about a SOAP exception for a PSI method.

Inheritance hierarchy

System.Object
  Microsoft.Office.Project.Server.Library.PSClientError

Namespace:  Microsoft.Office.Project.Server.Library
Assembly:  Microsoft.Office.Project.Server.Library (in Microsoft.Office.Project.Server.Library.dll)

Syntax

'Declaration
<SerializableAttribute> _
Public Class PSClientError _
    Implements ISerializable
'Usage
Dim instance As PSClientError
[SerializableAttribute]
public class PSClientError : ISerializable

Remarks

To get a list of all errors that occur if you get an exception when you call a PSI method, pass the SoapException object to the Microsoft.Office.Project.Server.Library.PSClientError class constructor. You can then use GetAllErrors to store the error information in a PSErrorInfo array and enumerate the errors, as in the following example.

Note

The PSErrorInfo object may not include all of the information you need. For example, if you use Resource.CheckOutResources where some of the resources are already checked out, PSErrorInfo shows the reason for failure for each resource that cannot be checked out, but does not include the resource name or GUID. For a way to get more information, see CheckOutResources.

Examples

using System;
using System.Collections.Generic;
using System.Text;
using System.Web.Services.Protocols;
using System.Windows.Forms;
using PSLibrary = Microsoft.Office.Project.Server.Library;
. . .
try
{
    /* call a PSI method */
}
catch (SoapException ex)
{
    string errAttributeName;
    string errAttribute;
    string errMess = "".PadRight(30, '=') + "\r\n" + "Error: " + "\r\n";

    PSLibrary.PSClientError error = new PSLibrary.PSClientError(ex);
    PSLibrary.PSErrorInfo[] errors = error.GetAllErrors();
    PSLibrary.PSErrorInfo thisError;

    for (int i = 0; i < errors.Length; i++)
    {
        thisError = errors[i];
        errMess += "\n" + ex.Message.ToString() + "\r\n";
        errMess += "".PadRight(30, '=') + "\r\nPSCLientError Output:\r\n \r\n";
        errMess += thisError.ErrId.ToString() + "\n";

        for (int j = 0; j < thisError.ErrorAttributes.Length; j++)
        {
            errAttributeName = thisError.ErrorAttributeNames()[j];
            errAttribute = thisError.ErrorAttributes[j];
            errMess += "\r\n\t" + errAttributeName +
                       ": " + errAttribute;
        }
        errMess += "\r\n".PadRight(30, '=');
    }
    MessageBox.Show(errMess, "Error", MessageBoxButtons.OK,
        MessageBoxIcon.Error);
}

Thread safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See also

Reference

PSClientError members

Microsoft.Office.Project.Server.Library namespace

CheckOutResources

Other resources

How to: Log on to Project Server Programmatically

Project Server 2013 error codes