@@ -13,11 +13,13 @@ public partial class NatsJSContext
13
13
/// <returns>The NATS JetStream stream object which can be used to manage the stream.</returns>
14
14
/// <exception cref="NatsJSException">There was an issue retrieving the response.</exception>
15
15
/// <exception cref="NatsJSApiException">Server responded with an error.</exception>
16
+ /// <exception cref="ArgumentException">The stream name in <paramref name="config"/> is invalid.</exception>
17
+ /// <exception cref="ArgumentNullException">The name in <paramref name="config"/> is <c>null</c>.</exception>
16
18
public async ValueTask < INatsJSStream > CreateStreamAsync (
17
19
StreamConfig config ,
18
20
CancellationToken cancellationToken = default )
19
21
{
20
- ArgumentNullException . ThrowIfNull ( config . Name , nameof ( config . Name ) ) ;
22
+ ThrowIfInvalidStreamName ( config . Name , nameof ( config . Name ) ) ;
21
23
var response = await JSRequestResponseAsync < StreamConfig , StreamInfo > (
22
24
subject : $ "{ Opts . Prefix } .STREAM.CREATE.{ config . Name } ",
23
25
config ,
@@ -33,10 +35,13 @@ public async ValueTask<INatsJSStream> CreateStreamAsync(
33
35
/// <returns>Whether delete was successful or not.</returns>
34
36
/// <exception cref="NatsJSException">There was an issue retrieving the response.</exception>
35
37
/// <exception cref="NatsJSApiException">Server responded with an error.</exception>
38
+ /// <exception cref="ArgumentException">The <paramref name="stream"/> name is invalid.</exception>
39
+ /// <exception cref="ArgumentNullException">The <paramref name="stream"/> name is <c>null</c>.</exception>
36
40
public async ValueTask < bool > DeleteStreamAsync (
37
41
string stream ,
38
42
CancellationToken cancellationToken = default )
39
43
{
44
+ ThrowIfInvalidStreamName ( stream ) ;
40
45
var response = await JSRequestResponseAsync < object , StreamMsgDeleteResponse > (
41
46
subject : $ "{ Opts . Prefix } .STREAM.DELETE.{ stream } ",
42
47
request : null ,
@@ -53,11 +58,14 @@ public async ValueTask<bool> DeleteStreamAsync(
53
58
/// <returns>Purge response</returns>
54
59
/// <exception cref="NatsJSException">There was an issue retrieving the response.</exception>
55
60
/// <exception cref="NatsJSApiException">Server responded with an error.</exception>
61
+ /// <exception cref="ArgumentException">The <paramref name="stream"/> name is invalid.</exception>
62
+ /// <exception cref="ArgumentNullException">The <paramref name="stream"/> name is <c>null</c>.</exception>
56
63
public async ValueTask < StreamPurgeResponse > PurgeStreamAsync (
57
64
string stream ,
58
65
StreamPurgeRequest request ,
59
66
CancellationToken cancellationToken = default )
60
67
{
68
+ ThrowIfInvalidStreamName ( stream ) ;
61
69
var response = await JSRequestResponseAsync < StreamPurgeRequest , StreamPurgeResponse > (
62
70
subject : $ "{ Opts . Prefix } .STREAM.PURGE.{ stream } ",
63
71
request : request ,
@@ -74,11 +82,14 @@ public async ValueTask<StreamPurgeResponse> PurgeStreamAsync(
74
82
/// <returns>Delete message response</returns>
75
83
/// <exception cref="NatsJSException">There was an issue retrieving the response.</exception>
76
84
/// <exception cref="NatsJSApiException">Server responded with an error.</exception>
85
+ /// <exception cref="ArgumentException">The <paramref name="stream"/> name is invalid.</exception>
86
+ /// <exception cref="ArgumentNullException">The <paramref name="stream"/> name is <c>null</c>.</exception>
77
87
public async ValueTask < StreamMsgDeleteResponse > DeleteMessageAsync (
78
88
string stream ,
79
89
StreamMsgDeleteRequest request ,
80
90
CancellationToken cancellationToken = default )
81
91
{
92
+ ThrowIfInvalidStreamName ( stream ) ;
82
93
var response = await JSRequestResponseAsync < StreamMsgDeleteRequest , StreamMsgDeleteResponse > (
83
94
subject : $ "{ Opts . Prefix } .STREAM.MSG.DELETE.{ stream } ",
84
95
request : request ,
@@ -95,11 +106,14 @@ public async ValueTask<StreamMsgDeleteResponse> DeleteMessageAsync(
95
106
/// <returns>The NATS JetStream stream object which can be used to manage the stream.</returns>
96
107
/// <exception cref="NatsJSException">There was an issue retrieving the response.</exception>
97
108
/// <exception cref="NatsJSApiException">Server responded with an error.</exception>
109
+ /// <exception cref="ArgumentException">The <paramref name="stream"/> name is invalid.</exception>
110
+ /// <exception cref="ArgumentNullException">The <paramref name="stream"/> name is <c>null</c>.</exception>
98
111
public async ValueTask < INatsJSStream > GetStreamAsync (
99
112
string stream ,
100
113
StreamInfoRequest ? request = null ,
101
114
CancellationToken cancellationToken = default )
102
115
{
116
+ ThrowIfInvalidStreamName ( stream ) ;
103
117
var response = await JSRequestResponseAsync < StreamInfoRequest , StreamInfoResponse > (
104
118
subject : $ "{ Opts . Prefix } .STREAM.INFO.{ stream } ",
105
119
request : request ,
@@ -115,11 +129,13 @@ public async ValueTask<INatsJSStream> GetStreamAsync(
115
129
/// <returns>The updated NATS JetStream stream object.</returns>
116
130
/// <exception cref="NatsJSException">There was an issue retrieving the response.</exception>
117
131
/// <exception cref="NatsJSApiException">Server responded with an error.</exception>
132
+ /// <exception cref="ArgumentException">The stream name in <paramref name="request"/> is invalid.</exception>
133
+ /// <exception cref="ArgumentNullException">The name in <paramref name="request"/> is <c>null</c>.</exception>
118
134
public async ValueTask < NatsJSStream > UpdateStreamAsync (
119
135
StreamConfig request ,
120
136
CancellationToken cancellationToken = default )
121
137
{
122
- ArgumentNullException . ThrowIfNull ( request . Name , nameof ( request . Name ) ) ;
138
+ ThrowIfInvalidStreamName ( request . Name , nameof ( request . Name ) ) ;
123
139
var response = await JSRequestResponseAsync < StreamConfig , StreamUpdateResponse > (
124
140
subject : $ "{ Opts . Prefix } .STREAM.UPDATE.{ request . Name } ",
125
141
request : request ,
0 commit comments