Skip to content

Commit 57fb9a4

Browse files
kirilyuroMpdreamz
authored andcommitted
Added ToString to Nest.CausedBy for proper string representation. (#2521)
1 parent fabf137 commit 57fb9a4

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/Nest/CommonOptions/Failures/BulkError.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ public class BulkError
2020
[JsonProperty("caused_by")]
2121
public CausedBy CausedBy { get; internal set; }
2222

23-
public override string ToString() => $"Type: {Type} Reason: \"{Reason}\" CausedBy: \"{CausedBy}\"";
23+
public override string ToString()
24+
{
25+
var cause = (CausedBy != null) ?
26+
$" CausedBy:\n{CausedBy}" :
27+
string.Empty;
28+
29+
return $"Type: {Type} Reason: \"{Reason}\"{cause}";
30+
}
2431
}
2532
}

src/Nest/CommonOptions/Failures/ShardFailure.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,14 @@ public class CausedBy : IFailureReason
4646

4747
[JsonProperty("caused_by")]
4848
public CausedBy InnerCausedBy { get; internal set; }
49+
50+
public override string ToString()
51+
{
52+
var innerCause = (InnerCausedBy != null) ?
53+
$" CausedBy:\n{InnerCausedBy}" :
54+
string.Empty;
55+
56+
return $"Type: {Type} Reason: \"{Reason}\"{innerCause}";
57+
}
4958
}
5059
}

0 commit comments

Comments
 (0)