Skip to content

Commit

Permalink
Merge branch 'release/1.3.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
sahb1239 committed Jan 9, 2019
2 parents a9ca719 + 23a2f29 commit d75e6cf
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/SAHB.GraphQLClient/Exceptions/GraphQLErrorException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,17 @@ private static string GetMessage(IEnumerable<GraphQLDataError> errors)

return string.Join(Environment.NewLine,
errors.Select(error =>
$"{error.Message ?? "Error"} at {Environment.NewLine}{string.Join(Environment.NewLine, error.Locations?.Select(location => " line: " + location.Line + " column: " + location.Column))}"));
$"{error.Message ?? "Error"} at {Environment.NewLine}{GetErrorLocation(error)}"));
}

private static string GetErrorLocation(GraphQLDataError error)
{
var errors = (error.Locations?.Select(location => " line: " + location?.Line + " column: " + location?.Column));
if (errors != null && errors.Any())
{
return string.Join(Environment.NewLine, errors);
}
return "Unknown location";
}

public IEnumerable<GraphQLDataError> Errors { get; }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Text;
using SAHB.GraphQLClient.Exceptions;
using SAHB.GraphQLClient.Result;
using Xunit;

namespace SAHB.GraphQLClient.Tests.Exceptions
{

public class GraphQLErrorExceptionTests
{
[Fact]
public void Get_Message_Should_Not_Throw_Exception()
{
var errorList = new List<GraphQLDataError> { new GraphQLDataError { Message = "Access denied." } };

new GraphQLErrorException("query", errorList);
}
}
}

0 comments on commit d75e6cf

Please sign in to comment.