Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge dev -> dui3/alpha #3564

Merged
merged 3 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Automate/Speckle.Automate.Sdk/AutomationContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Speckle.Automate.Sdk.Schema;
using Speckle.Automate.Sdk.Schema.Triggers;
using Speckle.Core.Api;
using Speckle.Core.Api.GraphQL.Models;
using Speckle.Core.Credentials;
using Speckle.Core.Logging;
using Speckle.Core.Models;
Expand Down
2 changes: 1 addition & 1 deletion Automate/Speckle.Automate.Sdk/Speckle.Automate.Sdk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<PropertyGroup Condition="'$(IsDesktopBuild)' == false">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningsNotAsErrors>$(WarningsNotAsErrors);CS8618;</WarningsNotAsErrors>
<WarningsNotAsErrors>$(WarningsNotAsErrors);CS8618;CS0618;</WarningsNotAsErrors>
</PropertyGroup>

<ItemGroup>
Expand Down
97 changes: 57 additions & 40 deletions Core/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
Loading