Partager via


PSClientError.GetAllErrors - Méthode

Obtient un tableau d'objets PSErrorInfo qui décrit toutes les erreurs en cours.

Espace de noms :  Microsoft.Office.Project.Server.Library
Assembly :  Microsoft.Office.Project.Server.Library (dans Microsoft.Office.Project.Server.Library.dll)

Syntaxe

'Déclaration
Public Function GetAllErrors As PSErrorInfo()
'Utilisation
Dim instance As PSClientError
Dim returnValue As PSErrorInfo()

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

Valeur renvoyée

Type : []

Remarques

Pour obtenir une liste de toutes les erreurs qui se produisent si vous obtenez une exception quand vous appelez une méthode PSI, transmettez l'objet SoapException au constructeur de classe Microsoft.Office.Project.Server.Library.PSClientError . Vous pouvez ensuite utiliser GetAllErrors pour stocker les informations d'erreur dans un tableau de PSErrorInfo et énumérer les erreurs, comme dans l'exemple suivant.

Notes

L'objet PSErrorInfo ne peut pas inclure toutes les informations dont vous avez besoin. Par exemple, si vous utilisez Resource.CheckOutResources où une des ressources est déjà extrait, PSErrorInfo indique la raison de l'échec de chaque ressource qui ne peut pas être extrait, mais n'inclut pas le nom de la ressource ou le GUID. Pour savoir comment obtenir plus d'informations, consultez la rubrique CheckOutResources.

Exemples

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);
}

Voir aussi

Référence

PSClientError classe

PSClientError - Membres

Microsoft.Office.Project.Server.Library - Espace de noms

CheckOutResources

Autres ressources

Procédure : se connecter à Project Server par programmation

Codes d’erreur de Project Server 2013