Meyn.TestLink.TestLink.handleErrorMessage C# (CSharp) Method

handleErrorMessage() private method

process the response object returned by the Tstlink API for error messages. if it finds one or more error messages it throws a TLINK Exception ///
private handleErrorMessage ( object errorMessage, int exceptedErrorCodes ) : bool
errorMessage object the actual message returned by testlink
exceptedErrorCodes int a list of integers that should not result in an exception to be processed
return bool
        private bool handleErrorMessage(object[] errorMessage, int[] exceptedErrorCodes)
        {
            List<TLErrorMessage> errs = decodeErrors(errorMessage);
            if (errs.Count > 0) {
                foreach (TLErrorMessage foundError in errs) {
                    bool matched = exceptedErrorCodes.Any(exceptedErrorCode => foundError.code == exceptedErrorCode);

                    /*
                    List<TLErrorMessage> errs = decodeErrors(errorMessage);
                    if (errs.Count > 0)
                    {
                        foreach (TLErrorMessage foundError in errs)
                        {
                            bool matched = false;
                            foreach (int exceptedErrorCode in exceptedErrorCodes)
                                if (foundError.code == exceptedErrorCode)
                                {
                                    matched = true;
                                    break;
                                }
                            // all must match or we throw an exception
                            if (!matched)
                            {
                                string msg = string.Format("{0}:{1}", errs[0].code, errs[0].message);
                                throw new TestLinkException(msg, errs);
                            }
                        }
                        return true;
                        // we have matched the errors to the exceptions
                    }
                    return false;
                        // there were no errors
                    */

                    // all must match or we throw an exception
                    if (!matched) {
                        string msg = string.Format("{0}:{1}", errs[0].code, errs[0].message);
                        throw new TestLinkException(msg, errs);
                    }
                }
                return true;
                // we have matched the errors to the exceptions
            }
            return false;
            // there were no errors
        }

Same methods

TestLink::handleErrorMessage ( object errorMessage ) : bool