Skip to content

Commit 386a09e

Browse files
authored
Adds Status as a strongly-typed property of LibPlcTagException. (#435)
1 parent 9930186 commit 386a09e

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

src/libplctag.Tests/AsyncTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public async Task Timeout_throws_a_LibPlcTagException()
7070
});
7171

7272
// Assert
73-
Assert.Equal(Status.ErrorTimeout.ToString(), ex.Message);
73+
Assert.Equal(Status.ErrorTimeout, ex.Status);
7474
}
7575

7676
[Fact]

src/libplctag.Tests/DisposeTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public async Task GithubIssue418()
6464
{
6565
await tag.InitializeAsync();
6666
}
67-
catch (Exception e) when (e.Message == "ErrorNotFound") // we are expecting this exception
67+
catch (LibPlcTagException e) when (e.Status == Status.ErrorNotFound) // we are expecting this exception
6868
{
6969
}
7070
}

src/libplctag/LibPlcTagException.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ namespace libplctag
1515
/// </summary>
1616
public class LibPlcTagException : Exception
1717
{
18+
public Status Status { get; }
19+
1820
public LibPlcTagException()
1921
{
2022
}
@@ -32,6 +34,7 @@ public LibPlcTagException(string message, Exception inner)
3234
public LibPlcTagException(Status status)
3335
: base(status.ToString())
3436
{
37+
Status = status;
3538
}
3639
}
3740
}

0 commit comments

Comments
 (0)