示例#1
0
 /// <summary>
 /// Throws an exception if certain conditions are met.
 /// </summary>
 /// <param name="objError"></param>
 /// <param name="serializer"></param>
 private static void ThrowIfError(object objError, JavaScriptSerializer serializer)
 {
     if (objError != null)
     {
         BrightcoveNestedError error = serializer.ConvertToType <BrightcoveNestedError>(objError);
         throw new BrightcoveApiException(error);
     }
 }
示例#2
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="nestedError">An encountered <see cref="BrightcoveNestedError"/>.</param>
        public BrightcoveApiException(BrightcoveNestedError nestedError)
        {
            _error = nestedError;

            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("An error was returned by the server while accessing the API: {0} (code {1})",
                            nestedError.Message, nestedError.Code);

            if (nestedError.Errors.Count > 0)
            {
                sb.AppendFormat("\nThe following errors were encountered:");
                foreach (BrightcoveNestedError error in nestedError.Errors)
                {
                    sb.AppendFormat("\n\t{0} (code {1})", error.Message, error.Code);
                }
            }

            _message = sb.ToString();
        }