Skip to content

Commit

Permalink
Merge sharp dui3/alpha -> sdk main (#16)
Browse files Browse the repository at this point in the history
* Merge

* csharpier format

* Fixed polysharp issues

* Integration Tests

* Fixes
  • Loading branch information
JR-Morgan authored Jul 9, 2024
1 parent 46c3f9d commit 1268a08
Show file tree
Hide file tree
Showing 93 changed files with 4,161 additions and 834 deletions.
97 changes: 57 additions & 40 deletions src/Speckle.Core/Api/Exceptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,50 +9,55 @@ namespace Speckle.Core.Api;
/// <summary>
/// Base class for GraphQL API exceptions
/// </summary>
public class SpeckleGraphQLException<T> : SpeckleException
public class SpeckleGraphQLException<T> : SpeckleGraphQLException
{
private readonly GraphQLRequest _request;
public GraphQLResponse<T>? Response { get; }

public SpeckleGraphQLException(string message, GraphQLRequest request, GraphQLResponse<T>? response)
: base(message)
{
_request = request;
Response = response;
}
public new GraphQLResponse<T>? Response => (GraphQLResponse<T>?)base.Response;

public SpeckleGraphQLException(string message, Exception inner, GraphQLRequest request, GraphQLResponse<T>? response)
: this(message, inner)
{
_request = request;
Response = response;
}
public SpeckleGraphQLException(
string message,
GraphQLRequest request,
GraphQLResponse<T>? response,
Exception? innerException = null
)
: base(message, request, response, innerException) { }

public SpeckleGraphQLException() { }

public SpeckleGraphQLException(string message)
public SpeckleGraphQLException(string? message)
: base(message) { }

public SpeckleGraphQLException(string message, Exception innerException)
public SpeckleGraphQLException(string? message, Exception? innerException)
: base(message, innerException) { }
}

public class SpeckleGraphQLException : SpeckleException
{
private readonly GraphQLRequest _request;
public IGraphQLResponse? Response { get; }

public IEnumerable<string> ErrorMessages =>
Response?.Errors != null ? Response.Errors.Select(e => e.Message) : Enumerable.Empty<string>();

public IDictionary<string, object>? Extensions => Response?.Extensions;
}

public class SpeckleGraphQLException : SpeckleGraphQLException<object>
{
public SpeckleGraphQLException(string message, GraphQLRequest request, GraphQLResponse<object>? response)
: base(message, request, response) { }
public SpeckleGraphQLException(
string? message,
GraphQLRequest request,
IGraphQLResponse? response,
Exception? innerException = null
)
: base(message, innerException)
{
_request = request;
Response = response;
}

public SpeckleGraphQLException() { }

public SpeckleGraphQLException(string message)
public SpeckleGraphQLException(string? message)
: base(message) { }

public SpeckleGraphQLException(string message, Exception innerException)
public SpeckleGraphQLException(string? message, Exception? innerException)
: base(message, innerException) { }
}

Expand All @@ -61,44 +66,56 @@ public SpeckleGraphQLException(string message, Exception innerException)
/// https://www.apollographql.com/docs/apollo-server/v2/data/errors/#unauthenticated
/// https://www.apollographql.com/docs/apollo-server/v2/data/errors/#forbidden
/// </summary>
public class SpeckleGraphQLForbiddenException<T> : SpeckleGraphQLException<T>
public class SpeckleGraphQLForbiddenException : SpeckleGraphQLException
{
public SpeckleGraphQLForbiddenException(GraphQLRequest request, GraphQLResponse<T> response)
: base("Your request was forbidden", request, response) { }
public SpeckleGraphQLForbiddenException(
GraphQLRequest request,
IGraphQLResponse response,
Exception? innerException = null
)
: base("Your request was forbidden", request, response, innerException) { }

public SpeckleGraphQLForbiddenException() { }

public SpeckleGraphQLForbiddenException(string message)
public SpeckleGraphQLForbiddenException(string? message)
: base(message) { }

public SpeckleGraphQLForbiddenException(string message, Exception innerException)
public SpeckleGraphQLForbiddenException(string? message, Exception? innerException)
: base(message, innerException) { }
}

public class SpeckleGraphQLInternalErrorException<T> : SpeckleGraphQLException<T>
public class SpeckleGraphQLInternalErrorException : SpeckleGraphQLException
{
public SpeckleGraphQLInternalErrorException(GraphQLRequest request, GraphQLResponse<T> response)
: base("Your request failed on the server side", request, response) { }
public SpeckleGraphQLInternalErrorException(
GraphQLRequest request,
IGraphQLResponse response,
Exception? innerException = null
)
: base("Your request failed on the server side", request, response, innerException) { }

public SpeckleGraphQLInternalErrorException() { }

public SpeckleGraphQLInternalErrorException(string message)
public SpeckleGraphQLInternalErrorException(string? message)
: base(message) { }

public SpeckleGraphQLInternalErrorException(string message, Exception innerException)
public SpeckleGraphQLInternalErrorException(string? message, Exception? innerException)
: base(message, innerException) { }
}

public class SpeckleGraphQLStreamNotFoundException<TStreamData> : SpeckleGraphQLException<TStreamData>
public class SpeckleGraphQLStreamNotFoundException : SpeckleGraphQLException
{
public SpeckleGraphQLStreamNotFoundException(GraphQLRequest request, GraphQLResponse<TStreamData> response)
: base("Stream not found", request, response) { }
public SpeckleGraphQLStreamNotFoundException(
GraphQLRequest request,
IGraphQLResponse response,
Exception? innerException = null
)
: base("Stream not found", request, response, innerException) { }

public SpeckleGraphQLStreamNotFoundException() { }

public SpeckleGraphQLStreamNotFoundException(string message)
public SpeckleGraphQLStreamNotFoundException(string? message)
: base(message) { }

public SpeckleGraphQLStreamNotFoundException(string message, Exception innerException)
public SpeckleGraphQLStreamNotFoundException(string? message, Exception? innerException)
: base(message, innerException) { }
}
Loading

0 comments on commit 1268a08

Please sign in to comment.