Partager via


PSClientError.GetAllErrors Method

Gets an array of PSErrorInfo objects describing all current errors.

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

Syntax

'Declaration
Public Function GetAllErrors As PSErrorInfo()
'Usage
Dim instance As PSClientError
Dim returnValue As PSErrorInfo()

returnValue = instance.GetAllErrors()
public PSErrorInfo[] GetAllErrors()

Return Value

Type: []

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 one of the resources is 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);
}

See Also

Reference

PSClientError Class

PSClientError Members

Microsoft.Office.Project.Server.Library Namespace

CheckOutResources

Other Resources

How to: Log on to Project Server Programmatically

Project Server Error Codes