diff --git a/src/generator/AutoRest.Ruby.Azure/TemplateModels/AzureMethodTemplateModel.cs b/src/generator/AutoRest.Ruby.Azure/TemplateModels/AzureMethodTemplateModel.cs index bfec27ea09..0e5e6fea21 100644 --- a/src/generator/AutoRest.Ruby.Azure/TemplateModels/AzureMethodTemplateModel.cs +++ b/src/generator/AutoRest.Ruby.Azure/TemplateModels/AzureMethodTemplateModel.cs @@ -8,6 +8,7 @@ using System.Net; using System.Text; using AutoRest.Core.ClientModel; +using AutoRest.Core.Logging; using AutoRest.Extensions.Azure; using AutoRest.Extensions.Azure.Model; using AutoRest.Ruby.Azure.Properties; @@ -274,8 +275,15 @@ public override string OperationReturnTypeString { if (Extensions.ContainsKey("nextMethodName") && !Extensions.ContainsKey(AzureExtensions.PageableExtension)) { - SequenceType sequenceType = ((CompositeType)ReturnType.Body).Properties.Select(p => p.Type).FirstOrDefault(t => t is SequenceType) as SequenceType; - return string.Format(CultureInfo.InvariantCulture, "Array<{0}>", sequenceType.ElementType.Name); + try + { + SequenceType sequenceType = ((CompositeType)ReturnType.Body).Properties.Select(p => p.Type).FirstOrDefault(t => t is SequenceType) as SequenceType; + return string.Format(CultureInfo.InvariantCulture, "Array<{0}>", sequenceType.ElementType.Name); + } + catch (NullReferenceException nr) + { + throw ErrorManager.CreateError(string.Format(CultureInfo.InvariantCulture, "No collection type exists in pageable operation return type: {0}", nr.StackTrace)); + } } return base.OperationReturnTypeString; }