Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public AccessDeniedException() : base("Access denied.") {

}

public static AccessDeniedException FromRpcException(RpcException ex) => FromRpcStatus(ex.GetRpcStatus()!);
public static AccessDeniedException FromRpcException(RpcException ex) =>
FromRpcStatus(ex.GetRpcStatus() ?? throw ex);

Comment thread
w1am marked this conversation as resolved.
public static AccessDeniedException FromRpcStatus(Google.Rpc.Status ex) {
return new(ex.Message, ex.ToRpcException());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public class AppendTransactionMaxSizeExceededException(int size, int maxSize, Ex
/// </summary>
public int MaxSize { get; } = maxSize;

public static AppendTransactionMaxSizeExceededException FromRpcException(RpcException ex) => FromRpcStatus(ex.GetRpcStatus()!);
public static AppendTransactionMaxSizeExceededException FromRpcException(RpcException ex) =>
FromRpcStatus(ex.GetRpcStatus() ?? throw ex);
Comment thread
w1am marked this conversation as resolved.

public static AppendTransactionMaxSizeExceededException FromRpcStatus(Google.Rpc.Status ex) {
var details = ex.GetDetail<AppendTransactionSizeExceededErrorDetails>();
Expand Down
3 changes: 2 additions & 1 deletion src/KurrentDB.Client/Core/Exceptions/NotLeaderException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ public NotLeaderException(string host, int port, Exception? exception = null) :
LeaderEndpoint = new DnsEndPoint(host, port);
}

public static NotLeaderException FromRpcException(RpcException ex) => FromRpcStatus(ex.GetRpcStatus()!);
public static NotLeaderException FromRpcException(RpcException ex) =>
FromRpcStatus(ex.GetRpcStatus() ?? throw ex);
Comment thread
w1am marked this conversation as resolved.

public static NotLeaderException FromRpcStatus(Google.Rpc.Status ex) {
var details = ex.GetDetail<NotLeaderNodeErrorDetails>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public StreamTombstonedException(string stream, Exception? exception = null)
Stream = stream;
}

public static StreamTombstonedException FromRpcException(RpcException ex) => FromRpcStatus(ex.GetRpcStatus()!);
public static StreamTombstonedException FromRpcException(RpcException ex) =>
FromRpcStatus(ex.GetRpcStatus() ?? throw ex);
Comment thread
w1am marked this conversation as resolved.

public static StreamTombstonedException FromRpcStatus(Google.Rpc.Status ex) {
var details = ex.GetDetail<StreamTombstonedErrorDetails>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public WrongExpectedVersionException(string streamName, StreamState expectedStre
ActualVersion = actualStreamState.ToInt64();
}

public static WrongExpectedVersionException FromRpcException(RpcException ex) => FromRpcStatus(ex.GetRpcStatus()!);
public static WrongExpectedVersionException FromRpcException(RpcException ex) =>
FromRpcStatus(ex.GetRpcStatus() ?? throw ex);
Comment thread
w1am marked this conversation as resolved.

public static WrongExpectedVersionException FromRpcStatus(Google.Rpc.Status ex) {
var details = ex.GetDetail<StreamRevisionConflictErrorDetails>();
Expand Down
3 changes: 1 addition & 2 deletions src/KurrentDB.Client/Streams/KurrentDBClient.MultiAppend.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ await session.RequestStream

return new MultiStreamAppendResponse(response.Position, responses);
} catch (RpcException ex) {
var status = ex.GetRpcStatus()!;
throw status.GetDetail<ErrorInfo>() switch {
throw ex.GetRpcStatus()?.GetDetail<ErrorInfo>() switch {
{ Reason: "STREAM_REVISION_CONFLICT" } => WrongExpectedVersionException.FromRpcException(ex),
Comment thread
w1am marked this conversation as resolved.
{ Reason: "STREAM_TOMBSTONED" } => StreamTombstonedException.FromRpcException(ex),
{ Reason: "APPEND_RECORD_SIZE_EXCEEDED" } => AppendRecordSizeExceededException.FromRpcException(ex),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public AppendRecordSizeExceededException(string stream, string recordId, long si
MaxSize = maxSize;
}

public static AppendRecordSizeExceededException FromRpcException(RpcException ex) => FromRpcStatus(ex.GetRpcStatus()!);
public static AppendRecordSizeExceededException FromRpcException(RpcException ex) =>
FromRpcStatus(ex.GetRpcStatus() ?? throw ex);
Comment thread
w1am marked this conversation as resolved.

public static AppendRecordSizeExceededException FromRpcStatus(Google.Rpc.Status ex) {
var details = ex.GetDetail<AppendRecordSizeExceededErrorDetails>();
Expand Down
Loading