• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nats-io / nats-server / 22050990587

13 Feb 2026 05:53PM UTC coverage: 83.783% (-0.8%) from 84.63%
22050990587

push

github

web-flow
Improved flow control for stream snapshots (#7828)

This PR improves the flow control for stream snapshots:

1. We will now keep a window of slots for in-flight chunks, rather than
counting totals and potentially dropping acks, but still targeting 8MB
in flight at any time
2. We will now wait for a chunk to be filled (or EOF from the
snapshotting goroutine) before sending it rather than opportunistically
sending smaller chunks, providing more stable throughput on the wire
3. Increase the amount of time that we can wait for acks from 2 seconds
to 5 seconds, to better cope with slow connections
4. Give up early in ack reply subscription handlers if we detect that
the process has failed

Signed-off-by: Neil Twigg <neil@nats.io>

74025 of 88353 relevant lines covered (83.78%)

350202.47 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

54.94
/server/jetstream_errors_generated.go
1
// Generated code, do not edit. See errors.json and run go generate to update
2

3
package server
4

5
import "strings"
6

7
const (
8
        // JSAccountResourcesExceededErr resource limits exceeded for account
9
        JSAccountResourcesExceededErr ErrorIdentifier = 10002
10

11
        // JSAtomicPublishContainsDuplicateMessageErr atomic publish batch contains duplicate message id
12
        JSAtomicPublishContainsDuplicateMessageErr ErrorIdentifier = 10201
13

14
        // JSAtomicPublishDisabledErr atomic publish is disabled
15
        JSAtomicPublishDisabledErr ErrorIdentifier = 10174
16

17
        // JSAtomicPublishIncompleteBatchErr atomic publish batch is incomplete
18
        JSAtomicPublishIncompleteBatchErr ErrorIdentifier = 10176
19

20
        // JSAtomicPublishInvalidBatchCommitErr atomic publish batch commit is invalid
21
        JSAtomicPublishInvalidBatchCommitErr ErrorIdentifier = 10200
22

23
        // JSAtomicPublishInvalidBatchIDErr atomic publish batch ID is invalid
24
        JSAtomicPublishInvalidBatchIDErr ErrorIdentifier = 10179
25

26
        // JSAtomicPublishMissingSeqErr atomic publish sequence is missing
27
        JSAtomicPublishMissingSeqErr ErrorIdentifier = 10175
28

29
        // JSAtomicPublishTooLargeBatchErrF atomic publish batch is too large: {size}
30
        JSAtomicPublishTooLargeBatchErrF ErrorIdentifier = 10199
31

32
        // JSAtomicPublishUnsupportedHeaderBatchErr atomic publish unsupported header used: {header}
33
        JSAtomicPublishUnsupportedHeaderBatchErr ErrorIdentifier = 10177
34

35
        // JSBadRequestErr bad request
36
        JSBadRequestErr ErrorIdentifier = 10003
37

38
        // JSClusterIncompleteErr incomplete results
39
        JSClusterIncompleteErr ErrorIdentifier = 10004
40

41
        // JSClusterNoPeersErrF Error causing no peers to be available ({err})
42
        JSClusterNoPeersErrF ErrorIdentifier = 10005
43

44
        // JSClusterNotActiveErr JetStream not in clustered mode
45
        JSClusterNotActiveErr ErrorIdentifier = 10006
46

47
        // JSClusterNotAssignedErr JetStream cluster not assigned to this server
48
        JSClusterNotAssignedErr ErrorIdentifier = 10007
49

50
        // JSClusterNotAvailErr JetStream system temporarily unavailable
51
        JSClusterNotAvailErr ErrorIdentifier = 10008
52

53
        // JSClusterNotLeaderErr JetStream cluster can not handle request
54
        JSClusterNotLeaderErr ErrorIdentifier = 10009
55

56
        // JSClusterPeerNotMemberErr peer not a member
57
        JSClusterPeerNotMemberErr ErrorIdentifier = 10040
58

59
        // JSClusterRequiredErr JetStream clustering support required
60
        JSClusterRequiredErr ErrorIdentifier = 10010
61

62
        // JSClusterServerMemberChangeInflightErr cluster member change is in progress
63
        JSClusterServerMemberChangeInflightErr ErrorIdentifier = 10202
64

65
        // JSClusterServerNotMemberErr server is not a member of the cluster
66
        JSClusterServerNotMemberErr ErrorIdentifier = 10044
67

68
        // JSClusterTagsErr tags placement not supported for operation
69
        JSClusterTagsErr ErrorIdentifier = 10011
70

71
        // JSClusterUnSupportFeatureErr not currently supported in clustered mode
72
        JSClusterUnSupportFeatureErr ErrorIdentifier = 10036
73

74
        // JSConsumerAckPolicyInvalidErr consumer ack policy invalid
75
        JSConsumerAckPolicyInvalidErr ErrorIdentifier = 10181
76

77
        // JSConsumerAckWaitNegativeErr consumer ack wait needs to be positive
78
        JSConsumerAckWaitNegativeErr ErrorIdentifier = 10183
79

80
        // JSConsumerAlreadyExists action CREATE is used for a existing consumer with a different config (consumer already exists)
81
        JSConsumerAlreadyExists ErrorIdentifier = 10148
82

83
        // JSConsumerBackOffNegativeErr consumer backoff needs to be positive
84
        JSConsumerBackOffNegativeErr ErrorIdentifier = 10184
85

86
        // JSConsumerBadDurableNameErr durable name can not contain '.', '*', '>'
87
        JSConsumerBadDurableNameErr ErrorIdentifier = 10103
88

89
        // JSConsumerConfigRequiredErr consumer config required
90
        JSConsumerConfigRequiredErr ErrorIdentifier = 10078
91

92
        // JSConsumerCreateDurableAndNameMismatch Consumer Durable and Name have to be equal if both are provided
93
        JSConsumerCreateDurableAndNameMismatch ErrorIdentifier = 10132
94

95
        // JSConsumerCreateErrF General consumer creation failure string ({err})
96
        JSConsumerCreateErrF ErrorIdentifier = 10012
97

98
        // JSConsumerCreateFilterSubjectMismatchErr Consumer create request did not match filtered subject from create subject
99
        JSConsumerCreateFilterSubjectMismatchErr ErrorIdentifier = 10131
100

101
        // JSConsumerDeliverCycleErr consumer deliver subject forms a cycle
102
        JSConsumerDeliverCycleErr ErrorIdentifier = 10081
103

104
        // JSConsumerDeliverToWildcardsErr consumer deliver subject has wildcards
105
        JSConsumerDeliverToWildcardsErr ErrorIdentifier = 10079
106

107
        // JSConsumerDescriptionTooLongErrF consumer description is too long, maximum allowed is {max}
108
        JSConsumerDescriptionTooLongErrF ErrorIdentifier = 10107
109

110
        // JSConsumerDirectRequiresEphemeralErr consumer direct requires an ephemeral consumer
111
        JSConsumerDirectRequiresEphemeralErr ErrorIdentifier = 10091
112

113
        // JSConsumerDirectRequiresPushErr consumer direct requires a push based consumer
114
        JSConsumerDirectRequiresPushErr ErrorIdentifier = 10090
115

116
        // JSConsumerDoesNotExist action UPDATE is used for a nonexisting consumer (consumer does not exist)
117
        JSConsumerDoesNotExist ErrorIdentifier = 10149
118

119
        // JSConsumerDuplicateFilterSubjects consumer cannot have both FilterSubject and FilterSubjects specified
120
        JSConsumerDuplicateFilterSubjects ErrorIdentifier = 10136
121

122
        // JSConsumerDurableNameNotInSubjectErr consumer expected to be durable but no durable name set in subject
123
        JSConsumerDurableNameNotInSubjectErr ErrorIdentifier = 10016
124

125
        // JSConsumerDurableNameNotMatchSubjectErr consumer name in subject does not match durable name in request
126
        JSConsumerDurableNameNotMatchSubjectErr ErrorIdentifier = 10017
127

128
        // JSConsumerDurableNameNotSetErr consumer expected to be durable but a durable name was not set
129
        JSConsumerDurableNameNotSetErr ErrorIdentifier = 10018
130

131
        // JSConsumerEmptyFilter consumer filter in FilterSubjects cannot be empty
132
        JSConsumerEmptyFilter ErrorIdentifier = 10139
133

134
        // JSConsumerEmptyGroupName Group name cannot be an empty string
135
        JSConsumerEmptyGroupName ErrorIdentifier = 10161
136

137
        // JSConsumerEphemeralWithDurableInSubjectErr consumer expected to be ephemeral but detected a durable name set in subject
138
        JSConsumerEphemeralWithDurableInSubjectErr ErrorIdentifier = 10019
139

140
        // JSConsumerEphemeralWithDurableNameErr consumer expected to be ephemeral but a durable name was set in request
141
        JSConsumerEphemeralWithDurableNameErr ErrorIdentifier = 10020
142

143
        // JSConsumerExistingActiveErr consumer already exists and is still active
144
        JSConsumerExistingActiveErr ErrorIdentifier = 10105
145

146
        // JSConsumerFCRequiresPushErr consumer flow control requires a push based consumer
147
        JSConsumerFCRequiresPushErr ErrorIdentifier = 10089
148

149
        // JSConsumerFilterNotSubsetErr consumer filter subject is not a valid subset of the interest subjects
150
        JSConsumerFilterNotSubsetErr ErrorIdentifier = 10093
151

152
        // JSConsumerHBRequiresPushErr consumer idle heartbeat requires a push based consumer
153
        JSConsumerHBRequiresPushErr ErrorIdentifier = 10088
154

155
        // JSConsumerInactiveThresholdExcess consumer inactive threshold exceeds system limit of {limit}
156
        JSConsumerInactiveThresholdExcess ErrorIdentifier = 10153
157

158
        // JSConsumerInvalidDeliverSubject invalid push consumer deliver subject
159
        JSConsumerInvalidDeliverSubject ErrorIdentifier = 10112
160

161
        // JSConsumerInvalidGroupNameErr Valid priority group name must match A-Z, a-z, 0-9, -_/=)+ and may not exceed 16 characters
162
        JSConsumerInvalidGroupNameErr ErrorIdentifier = 10162
163

164
        // JSConsumerInvalidPolicyErrF Generic delivery policy error ({err})
165
        JSConsumerInvalidPolicyErrF ErrorIdentifier = 10094
166

167
        // JSConsumerInvalidPriorityGroupErr Provided priority group does not exist for this consumer
168
        JSConsumerInvalidPriorityGroupErr ErrorIdentifier = 10160
169

170
        // JSConsumerInvalidResetErr invalid reset: {err}
171
        JSConsumerInvalidResetErr ErrorIdentifier = 10204
172

173
        // JSConsumerInvalidSamplingErrF failed to parse consumer sampling configuration: {err}
174
        JSConsumerInvalidSamplingErrF ErrorIdentifier = 10095
175

176
        // JSConsumerMaxDeliverBackoffErr max deliver is required to be > length of backoff values
177
        JSConsumerMaxDeliverBackoffErr ErrorIdentifier = 10116
178

179
        // JSConsumerMaxPendingAckExcessErrF consumer max ack pending exceeds system limit of {limit}
180
        JSConsumerMaxPendingAckExcessErrF ErrorIdentifier = 10121
181

182
        // JSConsumerMaxPendingAckPolicyRequiredErr consumer requires ack policy for max ack pending
183
        JSConsumerMaxPendingAckPolicyRequiredErr ErrorIdentifier = 10082
184

185
        // JSConsumerMaxRequestBatchExceededF consumer max request batch exceeds server limit of {limit}
186
        JSConsumerMaxRequestBatchExceededF ErrorIdentifier = 10125
187

188
        // JSConsumerMaxRequestBatchNegativeErr consumer max request batch needs to be > 0
189
        JSConsumerMaxRequestBatchNegativeErr ErrorIdentifier = 10114
190

191
        // JSConsumerMaxRequestExpiresTooSmall consumer max request expires needs to be >= 1ms
192
        JSConsumerMaxRequestExpiresTooSmall ErrorIdentifier = 10115
193

194
        // JSConsumerMaxWaitingNegativeErr consumer max waiting needs to be positive
195
        JSConsumerMaxWaitingNegativeErr ErrorIdentifier = 10087
196

197
        // JSConsumerMetadataLengthErrF consumer metadata exceeds maximum size of {limit}
198
        JSConsumerMetadataLengthErrF ErrorIdentifier = 10135
199

200
        // JSConsumerMultipleFiltersNotAllowed consumer with multiple subject filters cannot use subject based API
201
        JSConsumerMultipleFiltersNotAllowed ErrorIdentifier = 10137
202

203
        // JSConsumerNameContainsPathSeparatorsErr Consumer name can not contain path separators
204
        JSConsumerNameContainsPathSeparatorsErr ErrorIdentifier = 10127
205

206
        // JSConsumerNameExistErr consumer name already in use
207
        JSConsumerNameExistErr ErrorIdentifier = 10013
208

209
        // JSConsumerNameTooLongErrF consumer name is too long, maximum allowed is {max}
210
        JSConsumerNameTooLongErrF ErrorIdentifier = 10102
211

212
        // JSConsumerNotFoundErr consumer not found
213
        JSConsumerNotFoundErr ErrorIdentifier = 10014
214

215
        // JSConsumerOfflineErr consumer is offline
216
        JSConsumerOfflineErr ErrorIdentifier = 10119
217

218
        // JSConsumerOfflineReasonErrF consumer is offline: {err}
219
        JSConsumerOfflineReasonErrF ErrorIdentifier = 10195
220

221
        // JSConsumerOnMappedErr consumer direct on a mapped consumer
222
        JSConsumerOnMappedErr ErrorIdentifier = 10092
223

224
        // JSConsumerOverlappingSubjectFilters consumer subject filters cannot overlap
225
        JSConsumerOverlappingSubjectFilters ErrorIdentifier = 10138
226

227
        // JSConsumerPinnedTTLWithoutPriorityPolicyNone PinnedTTL cannot be set when PriorityPolicy is none
228
        JSConsumerPinnedTTLWithoutPriorityPolicyNone ErrorIdentifier = 10197
229

230
        // JSConsumerPriorityGroupWithPolicyNone consumer can not have priority groups when policy is none
231
        JSConsumerPriorityGroupWithPolicyNone ErrorIdentifier = 10196
232

233
        // JSConsumerPriorityPolicyWithoutGroup Setting PriorityPolicy requires at least one PriorityGroup to be set
234
        JSConsumerPriorityPolicyWithoutGroup ErrorIdentifier = 10159
235

236
        // JSConsumerPullNotDurableErr consumer in pull mode requires a durable name
237
        JSConsumerPullNotDurableErr ErrorIdentifier = 10085
238

239
        // JSConsumerPullRequiresAckErr consumer in pull mode requires explicit ack policy on workqueue stream
240
        JSConsumerPullRequiresAckErr ErrorIdentifier = 10084
241

242
        // JSConsumerPullWithRateLimitErr consumer in pull mode can not have rate limit set
243
        JSConsumerPullWithRateLimitErr ErrorIdentifier = 10086
244

245
        // JSConsumerPushMaxWaitingErr consumer in push mode can not set max waiting
246
        JSConsumerPushMaxWaitingErr ErrorIdentifier = 10080
247

248
        // JSConsumerPushWithPriorityGroupErr priority groups can not be used with push consumers
249
        JSConsumerPushWithPriorityGroupErr ErrorIdentifier = 10178
250

251
        // JSConsumerReplacementWithDifferentNameErr consumer replacement durable config not the same
252
        JSConsumerReplacementWithDifferentNameErr ErrorIdentifier = 10106
253

254
        // JSConsumerReplayPolicyInvalidErr consumer replay policy invalid
255
        JSConsumerReplayPolicyInvalidErr ErrorIdentifier = 10182
256

257
        // JSConsumerReplicasExceedsStream consumer config replica count exceeds parent stream
258
        JSConsumerReplicasExceedsStream ErrorIdentifier = 10126
259

260
        // JSConsumerReplicasShouldMatchStream consumer config replicas must match interest retention stream's replicas
261
        JSConsumerReplicasShouldMatchStream ErrorIdentifier = 10134
262

263
        // JSConsumerSmallHeartbeatErr consumer idle heartbeat needs to be >= 100ms
264
        JSConsumerSmallHeartbeatErr ErrorIdentifier = 10083
265

266
        // JSConsumerStoreFailedErrF error creating store for consumer: {err}
267
        JSConsumerStoreFailedErrF ErrorIdentifier = 10104
268

269
        // JSConsumerWQConsumerNotDeliverAllErr consumer must be deliver all on workqueue stream
270
        JSConsumerWQConsumerNotDeliverAllErr ErrorIdentifier = 10101
271

272
        // JSConsumerWQConsumerNotUniqueErr filtered consumer not unique on workqueue stream
273
        JSConsumerWQConsumerNotUniqueErr ErrorIdentifier = 10100
274

275
        // JSConsumerWQMultipleUnfilteredErr multiple non-filtered consumers not allowed on workqueue stream
276
        JSConsumerWQMultipleUnfilteredErr ErrorIdentifier = 10099
277

278
        // JSConsumerWQRequiresExplicitAckErr workqueue stream requires explicit ack
279
        JSConsumerWQRequiresExplicitAckErr ErrorIdentifier = 10098
280

281
        // JSConsumerWithFlowControlNeedsHeartbeats consumer with flow control also needs heartbeats
282
        JSConsumerWithFlowControlNeedsHeartbeats ErrorIdentifier = 10108
283

284
        // JSInsufficientResourcesErr insufficient resources
285
        JSInsufficientResourcesErr ErrorIdentifier = 10023
286

287
        // JSInvalidJSONErr invalid JSON: {err}
288
        JSInvalidJSONErr ErrorIdentifier = 10025
289

290
        // JSMaximumConsumersLimitErr maximum consumers limit reached
291
        JSMaximumConsumersLimitErr ErrorIdentifier = 10026
292

293
        // JSMaximumStreamsLimitErr maximum number of streams reached
294
        JSMaximumStreamsLimitErr ErrorIdentifier = 10027
295

296
        // JSMemoryResourcesExceededErr insufficient memory resources available
297
        JSMemoryResourcesExceededErr ErrorIdentifier = 10028
298

299
        // JSMessageCounterBrokenErr message counter is broken
300
        JSMessageCounterBrokenErr ErrorIdentifier = 10172
301

302
        // JSMessageIncrDisabledErr message counters is disabled
303
        JSMessageIncrDisabledErr ErrorIdentifier = 10168
304

305
        // JSMessageIncrInvalidErr message counter increment is invalid
306
        JSMessageIncrInvalidErr ErrorIdentifier = 10171
307

308
        // JSMessageIncrMissingErr message counter increment is missing
309
        JSMessageIncrMissingErr ErrorIdentifier = 10169
310

311
        // JSMessageIncrPayloadErr message counter has payload
312
        JSMessageIncrPayloadErr ErrorIdentifier = 10170
313

314
        // JSMessageSchedulesDisabledErr message schedules is disabled
315
        JSMessageSchedulesDisabledErr ErrorIdentifier = 10188
316

317
        // JSMessageSchedulesPatternInvalidErr message schedules pattern is invalid
318
        JSMessageSchedulesPatternInvalidErr ErrorIdentifier = 10189
319

320
        // JSMessageSchedulesRollupInvalidErr message schedules invalid rollup
321
        JSMessageSchedulesRollupInvalidErr ErrorIdentifier = 10192
322

323
        // JSMessageSchedulesSourceInvalidErr message schedules source is invalid
324
        JSMessageSchedulesSourceInvalidErr ErrorIdentifier = 10203
325

326
        // JSMessageSchedulesTTLInvalidErr message schedules invalid per-message TTL
327
        JSMessageSchedulesTTLInvalidErr ErrorIdentifier = 10191
328

329
        // JSMessageSchedulesTargetInvalidErr message schedules target is invalid
330
        JSMessageSchedulesTargetInvalidErr ErrorIdentifier = 10190
331

332
        // JSMessageTTLDisabledErr per-message TTL is disabled
333
        JSMessageTTLDisabledErr ErrorIdentifier = 10166
334

335
        // JSMessageTTLInvalidErr invalid per-message TTL
336
        JSMessageTTLInvalidErr ErrorIdentifier = 10165
337

338
        // JSMirrorConsumerSetupFailedErrF generic mirror consumer setup failure string ({err})
339
        JSMirrorConsumerSetupFailedErrF ErrorIdentifier = 10029
340

341
        // JSMirrorInvalidStreamName mirrored stream name is invalid
342
        JSMirrorInvalidStreamName ErrorIdentifier = 10142
343

344
        // JSMirrorInvalidSubjectFilter mirror transform source: {err}
345
        JSMirrorInvalidSubjectFilter ErrorIdentifier = 10151
346

347
        // JSMirrorInvalidTransformDestination mirror transform: {err}
348
        JSMirrorInvalidTransformDestination ErrorIdentifier = 10154
349

350
        // JSMirrorMaxMessageSizeTooBigErr stream mirror must have max message size >= source
351
        JSMirrorMaxMessageSizeTooBigErr ErrorIdentifier = 10030
352

353
        // JSMirrorMultipleFiltersNotAllowed mirror with multiple subject transforms cannot also have a single subject filter
354
        JSMirrorMultipleFiltersNotAllowed ErrorIdentifier = 10150
355

356
        // JSMirrorOverlappingSubjectFilters mirror subject filters can not overlap
357
        JSMirrorOverlappingSubjectFilters ErrorIdentifier = 10152
358

359
        // JSMirrorWithAtomicPublishErr stream mirrors can not also use atomic publishing
360
        JSMirrorWithAtomicPublishErr ErrorIdentifier = 10198
361

362
        // JSMirrorWithCountersErr stream mirrors can not also calculate counters
363
        JSMirrorWithCountersErr ErrorIdentifier = 10173
364

365
        // JSMirrorWithFirstSeqErr stream mirrors can not have first sequence configured
366
        JSMirrorWithFirstSeqErr ErrorIdentifier = 10143
367

368
        // JSMirrorWithMsgSchedulesErr stream mirrors can not also schedule messages
369
        JSMirrorWithMsgSchedulesErr ErrorIdentifier = 10186
370

371
        // JSMirrorWithSourcesErr stream mirrors can not also contain other sources
372
        JSMirrorWithSourcesErr ErrorIdentifier = 10031
373

374
        // JSMirrorWithStartSeqAndTimeErr stream mirrors can not have both start seq and start time configured
375
        JSMirrorWithStartSeqAndTimeErr ErrorIdentifier = 10032
376

377
        // JSMirrorWithSubjectFiltersErr stream mirrors can not contain filtered subjects
378
        JSMirrorWithSubjectFiltersErr ErrorIdentifier = 10033
379

380
        // JSMirrorWithSubjectsErr stream mirrors can not contain subjects
381
        JSMirrorWithSubjectsErr ErrorIdentifier = 10034
382

383
        // JSNoAccountErr account not found
384
        JSNoAccountErr ErrorIdentifier = 10035
385

386
        // JSNoLimitsErr no JetStream default or applicable tiered limit present
387
        JSNoLimitsErr ErrorIdentifier = 10120
388

389
        // JSNoMessageFoundErr no message found
390
        JSNoMessageFoundErr ErrorIdentifier = 10037
391

392
        // JSNotEmptyRequestErr expected an empty request payload
393
        JSNotEmptyRequestErr ErrorIdentifier = 10038
394

395
        // JSNotEnabledErr JetStream not enabled
396
        JSNotEnabledErr ErrorIdentifier = 10076
397

398
        // JSNotEnabledForAccountErr JetStream not enabled for account
399
        JSNotEnabledForAccountErr ErrorIdentifier = 10039
400

401
        // JSPedanticErrF pedantic mode: {err}
402
        JSPedanticErrF ErrorIdentifier = 10157
403

404
        // JSPeerRemapErr peer remap failed
405
        JSPeerRemapErr ErrorIdentifier = 10075
406

407
        // JSRaftGeneralErrF General RAFT error string ({err})
408
        JSRaftGeneralErrF ErrorIdentifier = 10041
409

410
        // JSReplicasCountCannotBeNegative replicas count cannot be negative
411
        JSReplicasCountCannotBeNegative ErrorIdentifier = 10133
412

413
        // JSRequiredApiLevelErr JetStream minimum api level required
414
        JSRequiredApiLevelErr ErrorIdentifier = 10185
415

416
        // JSRestoreSubscribeFailedErrF JetStream unable to subscribe to restore snapshot {subject}: {err}
417
        JSRestoreSubscribeFailedErrF ErrorIdentifier = 10042
418

419
        // JSSequenceNotFoundErrF sequence {seq} not found
420
        JSSequenceNotFoundErrF ErrorIdentifier = 10043
421

422
        // JSSnapshotDeliverSubjectInvalidErr deliver subject not valid
423
        JSSnapshotDeliverSubjectInvalidErr ErrorIdentifier = 10015
424

425
        // JSSourceConsumerSetupFailedErrF General source consumer setup failure string ({err})
426
        JSSourceConsumerSetupFailedErrF ErrorIdentifier = 10045
427

428
        // JSSourceDuplicateDetected source stream, filter and transform (plus external if present) must form a unique combination (duplicate source configuration detected)
429
        JSSourceDuplicateDetected ErrorIdentifier = 10140
430

431
        // JSSourceInvalidStreamName sourced stream name is invalid
432
        JSSourceInvalidStreamName ErrorIdentifier = 10141
433

434
        // JSSourceInvalidSubjectFilter source transform source: {err}
435
        JSSourceInvalidSubjectFilter ErrorIdentifier = 10145
436

437
        // JSSourceInvalidTransformDestination source transform: {err}
438
        JSSourceInvalidTransformDestination ErrorIdentifier = 10146
439

440
        // JSSourceMaxMessageSizeTooBigErr stream source must have max message size >= target
441
        JSSourceMaxMessageSizeTooBigErr ErrorIdentifier = 10046
442

443
        // JSSourceMultipleFiltersNotAllowed source with multiple subject transforms cannot also have a single subject filter
444
        JSSourceMultipleFiltersNotAllowed ErrorIdentifier = 10144
445

446
        // JSSourceOverlappingSubjectFilters source filters can not overlap
447
        JSSourceOverlappingSubjectFilters ErrorIdentifier = 10147
448

449
        // JSSourceWithMsgSchedulesErr stream source can not also schedule messages
450
        JSSourceWithMsgSchedulesErr ErrorIdentifier = 10187
451

452
        // JSStorageResourcesExceededErr insufficient storage resources available
453
        JSStorageResourcesExceededErr ErrorIdentifier = 10047
454

455
        // JSStreamAssignmentErrF Generic stream assignment error string ({err})
456
        JSStreamAssignmentErrF ErrorIdentifier = 10048
457

458
        // JSStreamCreateErrF Generic stream creation error string ({err})
459
        JSStreamCreateErrF ErrorIdentifier = 10049
460

461
        // JSStreamDeleteErrF General stream deletion error string ({err})
462
        JSStreamDeleteErrF ErrorIdentifier = 10050
463

464
        // JSStreamDuplicateMessageConflict duplicate message id is in process
465
        JSStreamDuplicateMessageConflict ErrorIdentifier = 10158
466

467
        // JSStreamExpectedLastSeqPerSubjectInvalid missing sequence for expected last sequence per subject
468
        JSStreamExpectedLastSeqPerSubjectInvalid ErrorIdentifier = 10193
469

470
        // JSStreamExpectedLastSeqPerSubjectNotReady expected last sequence per subject temporarily unavailable
471
        JSStreamExpectedLastSeqPerSubjectNotReady ErrorIdentifier = 10163
472

473
        // JSStreamExternalApiOverlapErrF stream external api prefix {prefix} must not overlap with {subject}
474
        JSStreamExternalApiOverlapErrF ErrorIdentifier = 10021
475

476
        // JSStreamExternalDelPrefixOverlapsErrF stream external delivery prefix {prefix} overlaps with stream subject {subject}
477
        JSStreamExternalDelPrefixOverlapsErrF ErrorIdentifier = 10022
478

479
        // JSStreamGeneralErrorF General stream failure string ({err})
480
        JSStreamGeneralErrorF ErrorIdentifier = 10051
481

482
        // JSStreamHeaderExceedsMaximumErr header size exceeds maximum allowed of 64k
483
        JSStreamHeaderExceedsMaximumErr ErrorIdentifier = 10097
484

485
        // JSStreamInfoMaxSubjectsErr subject details would exceed maximum allowed
486
        JSStreamInfoMaxSubjectsErr ErrorIdentifier = 10117
487

488
        // JSStreamInvalidConfigF Stream configuration validation error string ({err})
489
        JSStreamInvalidConfigF ErrorIdentifier = 10052
490

491
        // JSStreamInvalidErr stream not valid
492
        JSStreamInvalidErr ErrorIdentifier = 10096
493

494
        // JSStreamInvalidExternalDeliverySubjErrF stream external delivery prefix {prefix} must not contain wildcards
495
        JSStreamInvalidExternalDeliverySubjErrF ErrorIdentifier = 10024
496

497
        // JSStreamLimitsErrF General stream limits exceeded error string ({err})
498
        JSStreamLimitsErrF ErrorIdentifier = 10053
499

500
        // JSStreamMaxBytesRequired account requires a stream config to have max bytes set
501
        JSStreamMaxBytesRequired ErrorIdentifier = 10113
502

503
        // JSStreamMaxStreamBytesExceeded stream max bytes exceeds account limit max stream bytes
504
        JSStreamMaxStreamBytesExceeded ErrorIdentifier = 10122
505

506
        // JSStreamMessageExceedsMaximumErr message size exceeds maximum allowed
507
        JSStreamMessageExceedsMaximumErr ErrorIdentifier = 10054
508

509
        // JSStreamMinLastSeqErr min last sequence
510
        JSStreamMinLastSeqErr ErrorIdentifier = 10180
511

512
        // JSStreamMirrorNotUpdatableErr stream mirror configuration can not be updated
513
        JSStreamMirrorNotUpdatableErr ErrorIdentifier = 10055
514

515
        // JSStreamMismatchErr stream name in subject does not match request
516
        JSStreamMismatchErr ErrorIdentifier = 10056
517

518
        // JSStreamMoveAndScaleErr can not move and scale a stream in a single update
519
        JSStreamMoveAndScaleErr ErrorIdentifier = 10123
520

521
        // JSStreamMoveInProgressF stream move already in progress: {msg}
522
        JSStreamMoveInProgressF ErrorIdentifier = 10124
523

524
        // JSStreamMoveNotInProgress stream move not in progress
525
        JSStreamMoveNotInProgress ErrorIdentifier = 10129
526

527
        // JSStreamMsgDeleteFailedF Generic message deletion failure error string ({err})
528
        JSStreamMsgDeleteFailedF ErrorIdentifier = 10057
529

530
        // JSStreamNameContainsPathSeparatorsErr Stream name can not contain path separators
531
        JSStreamNameContainsPathSeparatorsErr ErrorIdentifier = 10128
532

533
        // JSStreamNameExistErr stream name already in use with a different configuration
534
        JSStreamNameExistErr ErrorIdentifier = 10058
535

536
        // JSStreamNameExistRestoreFailedErr stream name already in use, cannot restore
537
        JSStreamNameExistRestoreFailedErr ErrorIdentifier = 10130
538

539
        // JSStreamNotFoundErr stream not found
540
        JSStreamNotFoundErr ErrorIdentifier = 10059
541

542
        // JSStreamNotMatchErr expected stream does not match
543
        JSStreamNotMatchErr ErrorIdentifier = 10060
544

545
        // JSStreamOfflineErr stream is offline
546
        JSStreamOfflineErr ErrorIdentifier = 10118
547

548
        // JSStreamOfflineReasonErrF stream is offline: {err}
549
        JSStreamOfflineReasonErrF ErrorIdentifier = 10194
550

551
        // JSStreamPurgeFailedF Generic stream purge failure error string ({err})
552
        JSStreamPurgeFailedF ErrorIdentifier = 10110
553

554
        // JSStreamReplicasNotSupportedErr replicas > 1 not supported in non-clustered mode
555
        JSStreamReplicasNotSupportedErr ErrorIdentifier = 10074
556

557
        // JSStreamReplicasNotUpdatableErr Replicas configuration can not be updated
558
        JSStreamReplicasNotUpdatableErr ErrorIdentifier = 10061
559

560
        // JSStreamRestoreErrF restore failed: {err}
561
        JSStreamRestoreErrF ErrorIdentifier = 10062
562

563
        // JSStreamRollupFailedF Generic stream rollup failure error string ({err})
564
        JSStreamRollupFailedF ErrorIdentifier = 10111
565

566
        // JSStreamSealedErr invalid operation on sealed stream
567
        JSStreamSealedErr ErrorIdentifier = 10109
568

569
        // JSStreamSequenceNotMatchErr expected stream sequence does not match
570
        JSStreamSequenceNotMatchErr ErrorIdentifier = 10063
571

572
        // JSStreamSnapshotErrF snapshot failed: {err}
573
        JSStreamSnapshotErrF ErrorIdentifier = 10064
574

575
        // JSStreamStoreFailedF Generic error when storing a message failed ({err})
576
        JSStreamStoreFailedF ErrorIdentifier = 10077
577

578
        // JSStreamSubjectOverlapErr subjects overlap with an existing stream
579
        JSStreamSubjectOverlapErr ErrorIdentifier = 10065
580

581
        // JSStreamTemplateCreateErrF Generic template creation failed string ({err})
582
        JSStreamTemplateCreateErrF ErrorIdentifier = 10066
583

584
        // JSStreamTemplateDeleteErrF Generic stream template deletion failed error string ({err})
585
        JSStreamTemplateDeleteErrF ErrorIdentifier = 10067
586

587
        // JSStreamTemplateNotFoundErr template not found
588
        JSStreamTemplateNotFoundErr ErrorIdentifier = 10068
589

590
        // JSStreamTooManyRequests too many requests
591
        JSStreamTooManyRequests ErrorIdentifier = 10167
592

593
        // JSStreamTransformInvalidDestination stream transform: {err}
594
        JSStreamTransformInvalidDestination ErrorIdentifier = 10156
595

596
        // JSStreamTransformInvalidSource stream transform source: {err}
597
        JSStreamTransformInvalidSource ErrorIdentifier = 10155
598

599
        // JSStreamUpdateErrF Generic stream update error string ({err})
600
        JSStreamUpdateErrF ErrorIdentifier = 10069
601

602
        // JSStreamWrongLastMsgIDErrF wrong last msg ID: {id}
603
        JSStreamWrongLastMsgIDErrF ErrorIdentifier = 10070
604

605
        // JSStreamWrongLastSequenceConstantErr wrong last sequence
606
        JSStreamWrongLastSequenceConstantErr ErrorIdentifier = 10164
607

608
        // JSStreamWrongLastSequenceErrF wrong last sequence: {seq}
609
        JSStreamWrongLastSequenceErrF ErrorIdentifier = 10071
610

611
        // JSTempStorageFailedErr JetStream unable to open temp storage for restore
612
        JSTempStorageFailedErr ErrorIdentifier = 10072
613

614
        // JSTemplateNameNotMatchSubjectErr template name in subject does not match request
615
        JSTemplateNameNotMatchSubjectErr ErrorIdentifier = 10073
616
)
617

618
var (
619
        ApiErrors = map[ErrorIdentifier]*ApiError{
620
                JSAccountResourcesExceededErr:                {Code: 400, ErrCode: 10002, Description: "resource limits exceeded for account"},
621
                JSAtomicPublishContainsDuplicateMessageErr:   {Code: 400, ErrCode: 10201, Description: "atomic publish batch contains duplicate message id"},
622
                JSAtomicPublishDisabledErr:                   {Code: 400, ErrCode: 10174, Description: "atomic publish is disabled"},
623
                JSAtomicPublishIncompleteBatchErr:            {Code: 400, ErrCode: 10176, Description: "atomic publish batch is incomplete"},
624
                JSAtomicPublishInvalidBatchCommitErr:         {Code: 400, ErrCode: 10200, Description: "atomic publish batch commit is invalid"},
625
                JSAtomicPublishInvalidBatchIDErr:             {Code: 400, ErrCode: 10179, Description: "atomic publish batch ID is invalid"},
626
                JSAtomicPublishMissingSeqErr:                 {Code: 400, ErrCode: 10175, Description: "atomic publish sequence is missing"},
627
                JSAtomicPublishTooLargeBatchErrF:             {Code: 400, ErrCode: 10199, Description: "atomic publish batch is too large: {size}"},
628
                JSAtomicPublishUnsupportedHeaderBatchErr:     {Code: 400, ErrCode: 10177, Description: "atomic publish unsupported header used: {header}"},
629
                JSBadRequestErr:                              {Code: 400, ErrCode: 10003, Description: "bad request"},
630
                JSClusterIncompleteErr:                       {Code: 503, ErrCode: 10004, Description: "incomplete results"},
631
                JSClusterNoPeersErrF:                         {Code: 400, ErrCode: 10005, Description: "{err}"},
632
                JSClusterNotActiveErr:                        {Code: 500, ErrCode: 10006, Description: "JetStream not in clustered mode"},
633
                JSClusterNotAssignedErr:                      {Code: 500, ErrCode: 10007, Description: "JetStream cluster not assigned to this server"},
634
                JSClusterNotAvailErr:                         {Code: 503, ErrCode: 10008, Description: "JetStream system temporarily unavailable"},
635
                JSClusterNotLeaderErr:                        {Code: 500, ErrCode: 10009, Description: "JetStream cluster can not handle request"},
636
                JSClusterPeerNotMemberErr:                    {Code: 400, ErrCode: 10040, Description: "peer not a member"},
637
                JSClusterRequiredErr:                         {Code: 503, ErrCode: 10010, Description: "JetStream clustering support required"},
638
                JSClusterServerMemberChangeInflightErr:       {Code: 400, ErrCode: 10202, Description: "cluster member change is in progress"},
639
                JSClusterServerNotMemberErr:                  {Code: 400, ErrCode: 10044, Description: "server is not a member of the cluster"},
640
                JSClusterTagsErr:                             {Code: 400, ErrCode: 10011, Description: "tags placement not supported for operation"},
641
                JSClusterUnSupportFeatureErr:                 {Code: 503, ErrCode: 10036, Description: "not currently supported in clustered mode"},
642
                JSConsumerAckPolicyInvalidErr:                {Code: 400, ErrCode: 10181, Description: "consumer ack policy invalid"},
643
                JSConsumerAckWaitNegativeErr:                 {Code: 400, ErrCode: 10183, Description: "consumer ack wait needs to be positive"},
644
                JSConsumerAlreadyExists:                      {Code: 400, ErrCode: 10148, Description: "consumer already exists"},
645
                JSConsumerBackOffNegativeErr:                 {Code: 400, ErrCode: 10184, Description: "consumer backoff needs to be positive"},
646
                JSConsumerBadDurableNameErr:                  {Code: 400, ErrCode: 10103, Description: "durable name can not contain '.', '*', '>'"},
647
                JSConsumerConfigRequiredErr:                  {Code: 400, ErrCode: 10078, Description: "consumer config required"},
648
                JSConsumerCreateDurableAndNameMismatch:       {Code: 400, ErrCode: 10132, Description: "Consumer Durable and Name have to be equal if both are provided"},
649
                JSConsumerCreateErrF:                         {Code: 500, ErrCode: 10012, Description: "{err}"},
650
                JSConsumerCreateFilterSubjectMismatchErr:     {Code: 400, ErrCode: 10131, Description: "Consumer create request did not match filtered subject from create subject"},
651
                JSConsumerDeliverCycleErr:                    {Code: 400, ErrCode: 10081, Description: "consumer deliver subject forms a cycle"},
652
                JSConsumerDeliverToWildcardsErr:              {Code: 400, ErrCode: 10079, Description: "consumer deliver subject has wildcards"},
653
                JSConsumerDescriptionTooLongErrF:             {Code: 400, ErrCode: 10107, Description: "consumer description is too long, maximum allowed is {max}"},
654
                JSConsumerDirectRequiresEphemeralErr:         {Code: 400, ErrCode: 10091, Description: "consumer direct requires an ephemeral consumer"},
655
                JSConsumerDirectRequiresPushErr:              {Code: 400, ErrCode: 10090, Description: "consumer direct requires a push based consumer"},
656
                JSConsumerDoesNotExist:                       {Code: 400, ErrCode: 10149, Description: "consumer does not exist"},
657
                JSConsumerDuplicateFilterSubjects:            {Code: 400, ErrCode: 10136, Description: "consumer cannot have both FilterSubject and FilterSubjects specified"},
658
                JSConsumerDurableNameNotInSubjectErr:         {Code: 400, ErrCode: 10016, Description: "consumer expected to be durable but no durable name set in subject"},
659
                JSConsumerDurableNameNotMatchSubjectErr:      {Code: 400, ErrCode: 10017, Description: "consumer name in subject does not match durable name in request"},
660
                JSConsumerDurableNameNotSetErr:               {Code: 400, ErrCode: 10018, Description: "consumer expected to be durable but a durable name was not set"},
661
                JSConsumerEmptyFilter:                        {Code: 400, ErrCode: 10139, Description: "consumer filter in FilterSubjects cannot be empty"},
662
                JSConsumerEmptyGroupName:                     {Code: 400, ErrCode: 10161, Description: "Group name cannot be an empty string"},
663
                JSConsumerEphemeralWithDurableInSubjectErr:   {Code: 400, ErrCode: 10019, Description: "consumer expected to be ephemeral but detected a durable name set in subject"},
664
                JSConsumerEphemeralWithDurableNameErr:        {Code: 400, ErrCode: 10020, Description: "consumer expected to be ephemeral but a durable name was set in request"},
665
                JSConsumerExistingActiveErr:                  {Code: 400, ErrCode: 10105, Description: "consumer already exists and is still active"},
666
                JSConsumerFCRequiresPushErr:                  {Code: 400, ErrCode: 10089, Description: "consumer flow control requires a push based consumer"},
667
                JSConsumerFilterNotSubsetErr:                 {Code: 400, ErrCode: 10093, Description: "consumer filter subject is not a valid subset of the interest subjects"},
668
                JSConsumerHBRequiresPushErr:                  {Code: 400, ErrCode: 10088, Description: "consumer idle heartbeat requires a push based consumer"},
669
                JSConsumerInactiveThresholdExcess:            {Code: 400, ErrCode: 10153, Description: "consumer inactive threshold exceeds system limit of {limit}"},
670
                JSConsumerInvalidDeliverSubject:              {Code: 400, ErrCode: 10112, Description: "invalid push consumer deliver subject"},
671
                JSConsumerInvalidGroupNameErr:                {Code: 400, ErrCode: 10162, Description: "Valid priority group name must match A-Z, a-z, 0-9, -_/=)+ and may not exceed 16 characters"},
672
                JSConsumerInvalidPolicyErrF:                  {Code: 400, ErrCode: 10094, Description: "{err}"},
673
                JSConsumerInvalidPriorityGroupErr:            {Code: 400, ErrCode: 10160, Description: "Provided priority group does not exist for this consumer"},
674
                JSConsumerInvalidResetErr:                    {Code: 400, ErrCode: 10204, Description: "invalid reset: {err}"},
675
                JSConsumerInvalidSamplingErrF:                {Code: 400, ErrCode: 10095, Description: "failed to parse consumer sampling configuration: {err}"},
676
                JSConsumerMaxDeliverBackoffErr:               {Code: 400, ErrCode: 10116, Description: "max deliver is required to be > length of backoff values"},
677
                JSConsumerMaxPendingAckExcessErrF:            {Code: 400, ErrCode: 10121, Description: "consumer max ack pending exceeds system limit of {limit}"},
678
                JSConsumerMaxPendingAckPolicyRequiredErr:     {Code: 400, ErrCode: 10082, Description: "consumer requires ack policy for max ack pending"},
679
                JSConsumerMaxRequestBatchExceededF:           {Code: 400, ErrCode: 10125, Description: "consumer max request batch exceeds server limit of {limit}"},
680
                JSConsumerMaxRequestBatchNegativeErr:         {Code: 400, ErrCode: 10114, Description: "consumer max request batch needs to be > 0"},
681
                JSConsumerMaxRequestExpiresTooSmall:          {Code: 400, ErrCode: 10115, Description: "consumer max request expires needs to be >= 1ms"},
682
                JSConsumerMaxWaitingNegativeErr:              {Code: 400, ErrCode: 10087, Description: "consumer max waiting needs to be positive"},
683
                JSConsumerMetadataLengthErrF:                 {Code: 400, ErrCode: 10135, Description: "consumer metadata exceeds maximum size of {limit}"},
684
                JSConsumerMultipleFiltersNotAllowed:          {Code: 400, ErrCode: 10137, Description: "consumer with multiple subject filters cannot use subject based API"},
685
                JSConsumerNameContainsPathSeparatorsErr:      {Code: 400, ErrCode: 10127, Description: "Consumer name can not contain path separators"},
686
                JSConsumerNameExistErr:                       {Code: 400, ErrCode: 10013, Description: "consumer name already in use"},
687
                JSConsumerNameTooLongErrF:                    {Code: 400, ErrCode: 10102, Description: "consumer name is too long, maximum allowed is {max}"},
688
                JSConsumerNotFoundErr:                        {Code: 404, ErrCode: 10014, Description: "consumer not found"},
689
                JSConsumerOfflineErr:                         {Code: 500, ErrCode: 10119, Description: "consumer is offline"},
690
                JSConsumerOfflineReasonErrF:                  {Code: 500, ErrCode: 10195, Description: "consumer is offline: {err}"},
691
                JSConsumerOnMappedErr:                        {Code: 400, ErrCode: 10092, Description: "consumer direct on a mapped consumer"},
692
                JSConsumerOverlappingSubjectFilters:          {Code: 400, ErrCode: 10138, Description: "consumer subject filters cannot overlap"},
693
                JSConsumerPinnedTTLWithoutPriorityPolicyNone: {Code: 400, ErrCode: 10197, Description: "PinnedTTL cannot be set when PriorityPolicy is none"},
694
                JSConsumerPriorityGroupWithPolicyNone:        {Code: 400, ErrCode: 10196, Description: "consumer can not have priority groups when policy is none"},
695
                JSConsumerPriorityPolicyWithoutGroup:         {Code: 400, ErrCode: 10159, Description: "Setting PriorityPolicy requires at least one PriorityGroup to be set"},
696
                JSConsumerPullNotDurableErr:                  {Code: 400, ErrCode: 10085, Description: "consumer in pull mode requires a durable name"},
697
                JSConsumerPullRequiresAckErr:                 {Code: 400, ErrCode: 10084, Description: "consumer in pull mode requires explicit ack policy on workqueue stream"},
698
                JSConsumerPullWithRateLimitErr:               {Code: 400, ErrCode: 10086, Description: "consumer in pull mode can not have rate limit set"},
699
                JSConsumerPushMaxWaitingErr:                  {Code: 400, ErrCode: 10080, Description: "consumer in push mode can not set max waiting"},
700
                JSConsumerPushWithPriorityGroupErr:           {Code: 400, ErrCode: 10178, Description: "priority groups can not be used with push consumers"},
701
                JSConsumerReplacementWithDifferentNameErr:    {Code: 400, ErrCode: 10106, Description: "consumer replacement durable config not the same"},
702
                JSConsumerReplayPolicyInvalidErr:             {Code: 400, ErrCode: 10182, Description: "consumer replay policy invalid"},
703
                JSConsumerReplicasExceedsStream:              {Code: 400, ErrCode: 10126, Description: "consumer config replica count exceeds parent stream"},
704
                JSConsumerReplicasShouldMatchStream:          {Code: 400, ErrCode: 10134, Description: "consumer config replicas must match interest retention stream's replicas"},
705
                JSConsumerSmallHeartbeatErr:                  {Code: 400, ErrCode: 10083, Description: "consumer idle heartbeat needs to be >= 100ms"},
706
                JSConsumerStoreFailedErrF:                    {Code: 500, ErrCode: 10104, Description: "error creating store for consumer: {err}"},
707
                JSConsumerWQConsumerNotDeliverAllErr:         {Code: 400, ErrCode: 10101, Description: "consumer must be deliver all on workqueue stream"},
708
                JSConsumerWQConsumerNotUniqueErr:             {Code: 400, ErrCode: 10100, Description: "filtered consumer not unique on workqueue stream"},
709
                JSConsumerWQMultipleUnfilteredErr:            {Code: 400, ErrCode: 10099, Description: "multiple non-filtered consumers not allowed on workqueue stream"},
710
                JSConsumerWQRequiresExplicitAckErr:           {Code: 400, ErrCode: 10098, Description: "workqueue stream requires explicit ack"},
711
                JSConsumerWithFlowControlNeedsHeartbeats:     {Code: 400, ErrCode: 10108, Description: "consumer with flow control also needs heartbeats"},
712
                JSInsufficientResourcesErr:                   {Code: 503, ErrCode: 10023, Description: "insufficient resources"},
713
                JSInvalidJSONErr:                             {Code: 400, ErrCode: 10025, Description: "invalid JSON: {err}"},
714
                JSMaximumConsumersLimitErr:                   {Code: 400, ErrCode: 10026, Description: "maximum consumers limit reached"},
715
                JSMaximumStreamsLimitErr:                     {Code: 400, ErrCode: 10027, Description: "maximum number of streams reached"},
716
                JSMemoryResourcesExceededErr:                 {Code: 500, ErrCode: 10028, Description: "insufficient memory resources available"},
717
                JSMessageCounterBrokenErr:                    {Code: 400, ErrCode: 10172, Description: "message counter is broken"},
718
                JSMessageIncrDisabledErr:                     {Code: 400, ErrCode: 10168, Description: "message counters is disabled"},
719
                JSMessageIncrInvalidErr:                      {Code: 400, ErrCode: 10171, Description: "message counter increment is invalid"},
720
                JSMessageIncrMissingErr:                      {Code: 400, ErrCode: 10169, Description: "message counter increment is missing"},
721
                JSMessageIncrPayloadErr:                      {Code: 400, ErrCode: 10170, Description: "message counter has payload"},
722
                JSMessageSchedulesDisabledErr:                {Code: 400, ErrCode: 10188, Description: "message schedules is disabled"},
723
                JSMessageSchedulesPatternInvalidErr:          {Code: 400, ErrCode: 10189, Description: "message schedules pattern is invalid"},
724
                JSMessageSchedulesRollupInvalidErr:           {Code: 400, ErrCode: 10192, Description: "message schedules invalid rollup"},
725
                JSMessageSchedulesSourceInvalidErr:           {Code: 400, ErrCode: 10203, Description: "message schedules source is invalid"},
726
                JSMessageSchedulesTTLInvalidErr:              {Code: 400, ErrCode: 10191, Description: "message schedules invalid per-message TTL"},
727
                JSMessageSchedulesTargetInvalidErr:           {Code: 400, ErrCode: 10190, Description: "message schedules target is invalid"},
728
                JSMessageTTLDisabledErr:                      {Code: 400, ErrCode: 10166, Description: "per-message TTL is disabled"},
729
                JSMessageTTLInvalidErr:                       {Code: 400, ErrCode: 10165, Description: "invalid per-message TTL"},
730
                JSMirrorConsumerSetupFailedErrF:              {Code: 500, ErrCode: 10029, Description: "{err}"},
731
                JSMirrorInvalidStreamName:                    {Code: 400, ErrCode: 10142, Description: "mirrored stream name is invalid"},
732
                JSMirrorInvalidSubjectFilter:                 {Code: 400, ErrCode: 10151, Description: "mirror transform source: {err}"},
733
                JSMirrorInvalidTransformDestination:          {Code: 400, ErrCode: 10154, Description: "mirror transform: {err}"},
734
                JSMirrorMaxMessageSizeTooBigErr:              {Code: 400, ErrCode: 10030, Description: "stream mirror must have max message size >= source"},
735
                JSMirrorMultipleFiltersNotAllowed:            {Code: 400, ErrCode: 10150, Description: "mirror with multiple subject transforms cannot also have a single subject filter"},
736
                JSMirrorOverlappingSubjectFilters:            {Code: 400, ErrCode: 10152, Description: "mirror subject filters can not overlap"},
737
                JSMirrorWithAtomicPublishErr:                 {Code: 400, ErrCode: 10198, Description: "stream mirrors can not also use atomic publishing"},
738
                JSMirrorWithCountersErr:                      {Code: 400, ErrCode: 10173, Description: "stream mirrors can not also calculate counters"},
739
                JSMirrorWithFirstSeqErr:                      {Code: 400, ErrCode: 10143, Description: "stream mirrors can not have first sequence configured"},
740
                JSMirrorWithMsgSchedulesErr:                  {Code: 400, ErrCode: 10186, Description: "stream mirrors can not also schedule messages"},
741
                JSMirrorWithSourcesErr:                       {Code: 400, ErrCode: 10031, Description: "stream mirrors can not also contain other sources"},
742
                JSMirrorWithStartSeqAndTimeErr:               {Code: 400, ErrCode: 10032, Description: "stream mirrors can not have both start seq and start time configured"},
743
                JSMirrorWithSubjectFiltersErr:                {Code: 400, ErrCode: 10033, Description: "stream mirrors can not contain filtered subjects"},
744
                JSMirrorWithSubjectsErr:                      {Code: 400, ErrCode: 10034, Description: "stream mirrors can not contain subjects"},
745
                JSNoAccountErr:                               {Code: 503, ErrCode: 10035, Description: "account not found"},
746
                JSNoLimitsErr:                                {Code: 400, ErrCode: 10120, Description: "no JetStream default or applicable tiered limit present"},
747
                JSNoMessageFoundErr:                          {Code: 404, ErrCode: 10037, Description: "no message found"},
748
                JSNotEmptyRequestErr:                         {Code: 400, ErrCode: 10038, Description: "expected an empty request payload"},
749
                JSNotEnabledErr:                              {Code: 503, ErrCode: 10076, Description: "JetStream not enabled"},
750
                JSNotEnabledForAccountErr:                    {Code: 503, ErrCode: 10039, Description: "JetStream not enabled for account"},
751
                JSPedanticErrF:                               {Code: 400, ErrCode: 10157, Description: "pedantic mode: {err}"},
752
                JSPeerRemapErr:                               {Code: 503, ErrCode: 10075, Description: "peer remap failed"},
753
                JSRaftGeneralErrF:                            {Code: 500, ErrCode: 10041, Description: "{err}"},
754
                JSReplicasCountCannotBeNegative:              {Code: 400, ErrCode: 10133, Description: "replicas count cannot be negative"},
755
                JSRequiredApiLevelErr:                        {Code: 412, ErrCode: 10185, Description: "JetStream minimum api level required"},
756
                JSRestoreSubscribeFailedErrF:                 {Code: 500, ErrCode: 10042, Description: "JetStream unable to subscribe to restore snapshot {subject}: {err}"},
757
                JSSequenceNotFoundErrF:                       {Code: 400, ErrCode: 10043, Description: "sequence {seq} not found"},
758
                JSSnapshotDeliverSubjectInvalidErr:           {Code: 400, ErrCode: 10015, Description: "deliver subject not valid"},
759
                JSSourceConsumerSetupFailedErrF:              {Code: 500, ErrCode: 10045, Description: "{err}"},
760
                JSSourceDuplicateDetected:                    {Code: 400, ErrCode: 10140, Description: "duplicate source configuration detected"},
761
                JSSourceInvalidStreamName:                    {Code: 400, ErrCode: 10141, Description: "sourced stream name is invalid"},
762
                JSSourceInvalidSubjectFilter:                 {Code: 400, ErrCode: 10145, Description: "source transform source: {err}"},
763
                JSSourceInvalidTransformDestination:          {Code: 400, ErrCode: 10146, Description: "source transform: {err}"},
764
                JSSourceMaxMessageSizeTooBigErr:              {Code: 400, ErrCode: 10046, Description: "stream source must have max message size >= target"},
765
                JSSourceMultipleFiltersNotAllowed:            {Code: 400, ErrCode: 10144, Description: "source with multiple subject transforms cannot also have a single subject filter"},
766
                JSSourceOverlappingSubjectFilters:            {Code: 400, ErrCode: 10147, Description: "source filters can not overlap"},
767
                JSSourceWithMsgSchedulesErr:                  {Code: 400, ErrCode: 10187, Description: "stream source can not also schedule messages"},
768
                JSStorageResourcesExceededErr:                {Code: 500, ErrCode: 10047, Description: "insufficient storage resources available"},
769
                JSStreamAssignmentErrF:                       {Code: 500, ErrCode: 10048, Description: "{err}"},
770
                JSStreamCreateErrF:                           {Code: 500, ErrCode: 10049, Description: "{err}"},
771
                JSStreamDeleteErrF:                           {Code: 500, ErrCode: 10050, Description: "{err}"},
772
                JSStreamDuplicateMessageConflict:             {Code: 409, ErrCode: 10158, Description: "duplicate message id is in process"},
773
                JSStreamExpectedLastSeqPerSubjectInvalid:     {Code: 400, ErrCode: 10193, Description: "missing sequence for expected last sequence per subject"},
774
                JSStreamExpectedLastSeqPerSubjectNotReady:    {Code: 503, ErrCode: 10163, Description: "expected last sequence per subject temporarily unavailable"},
775
                JSStreamExternalApiOverlapErrF:               {Code: 400, ErrCode: 10021, Description: "stream external api prefix {prefix} must not overlap with {subject}"},
776
                JSStreamExternalDelPrefixOverlapsErrF:        {Code: 400, ErrCode: 10022, Description: "stream external delivery prefix {prefix} overlaps with stream subject {subject}"},
777
                JSStreamGeneralErrorF:                        {Code: 500, ErrCode: 10051, Description: "{err}"},
778
                JSStreamHeaderExceedsMaximumErr:              {Code: 400, ErrCode: 10097, Description: "header size exceeds maximum allowed of 64k"},
779
                JSStreamInfoMaxSubjectsErr:                   {Code: 500, ErrCode: 10117, Description: "subject details would exceed maximum allowed"},
780
                JSStreamInvalidConfigF:                       {Code: 500, ErrCode: 10052, Description: "{err}"},
781
                JSStreamInvalidErr:                           {Code: 500, ErrCode: 10096, Description: "stream not valid"},
782
                JSStreamInvalidExternalDeliverySubjErrF:      {Code: 400, ErrCode: 10024, Description: "stream external delivery prefix {prefix} must not contain wildcards"},
783
                JSStreamLimitsErrF:                           {Code: 500, ErrCode: 10053, Description: "{err}"},
784
                JSStreamMaxBytesRequired:                     {Code: 400, ErrCode: 10113, Description: "account requires a stream config to have max bytes set"},
785
                JSStreamMaxStreamBytesExceeded:               {Code: 400, ErrCode: 10122, Description: "stream max bytes exceeds account limit max stream bytes"},
786
                JSStreamMessageExceedsMaximumErr:             {Code: 400, ErrCode: 10054, Description: "message size exceeds maximum allowed"},
787
                JSStreamMinLastSeqErr:                        {Code: 412, ErrCode: 10180, Description: "min last sequence"},
788
                JSStreamMirrorNotUpdatableErr:                {Code: 400, ErrCode: 10055, Description: "stream mirror configuration can not be updated"},
789
                JSStreamMismatchErr:                          {Code: 400, ErrCode: 10056, Description: "stream name in subject does not match request"},
790
                JSStreamMoveAndScaleErr:                      {Code: 400, ErrCode: 10123, Description: "can not move and scale a stream in a single update"},
791
                JSStreamMoveInProgressF:                      {Code: 400, ErrCode: 10124, Description: "stream move already in progress: {msg}"},
792
                JSStreamMoveNotInProgress:                    {Code: 400, ErrCode: 10129, Description: "stream move not in progress"},
793
                JSStreamMsgDeleteFailedF:                     {Code: 500, ErrCode: 10057, Description: "{err}"},
794
                JSStreamNameContainsPathSeparatorsErr:        {Code: 400, ErrCode: 10128, Description: "Stream name can not contain path separators"},
795
                JSStreamNameExistErr:                         {Code: 400, ErrCode: 10058, Description: "stream name already in use with a different configuration"},
796
                JSStreamNameExistRestoreFailedErr:            {Code: 400, ErrCode: 10130, Description: "stream name already in use, cannot restore"},
797
                JSStreamNotFoundErr:                          {Code: 404, ErrCode: 10059, Description: "stream not found"},
798
                JSStreamNotMatchErr:                          {Code: 400, ErrCode: 10060, Description: "expected stream does not match"},
799
                JSStreamOfflineErr:                           {Code: 500, ErrCode: 10118, Description: "stream is offline"},
800
                JSStreamOfflineReasonErrF:                    {Code: 500, ErrCode: 10194, Description: "stream is offline: {err}"},
801
                JSStreamPurgeFailedF:                         {Code: 500, ErrCode: 10110, Description: "{err}"},
802
                JSStreamReplicasNotSupportedErr:              {Code: 500, ErrCode: 10074, Description: "replicas > 1 not supported in non-clustered mode"},
803
                JSStreamReplicasNotUpdatableErr:              {Code: 400, ErrCode: 10061, Description: "Replicas configuration can not be updated"},
804
                JSStreamRestoreErrF:                          {Code: 500, ErrCode: 10062, Description: "restore failed: {err}"},
805
                JSStreamRollupFailedF:                        {Code: 500, ErrCode: 10111, Description: "{err}"},
806
                JSStreamSealedErr:                            {Code: 400, ErrCode: 10109, Description: "invalid operation on sealed stream"},
807
                JSStreamSequenceNotMatchErr:                  {Code: 503, ErrCode: 10063, Description: "expected stream sequence does not match"},
808
                JSStreamSnapshotErrF:                         {Code: 500, ErrCode: 10064, Description: "snapshot failed: {err}"},
809
                JSStreamStoreFailedF:                         {Code: 503, ErrCode: 10077, Description: "{err}"},
810
                JSStreamSubjectOverlapErr:                    {Code: 400, ErrCode: 10065, Description: "subjects overlap with an existing stream"},
811
                JSStreamTemplateCreateErrF:                   {Code: 500, ErrCode: 10066, Description: "{err}"},
812
                JSStreamTemplateDeleteErrF:                   {Code: 500, ErrCode: 10067, Description: "{err}"},
813
                JSStreamTemplateNotFoundErr:                  {Code: 404, ErrCode: 10068, Description: "template not found"},
814
                JSStreamTooManyRequests:                      {Code: 429, ErrCode: 10167, Description: "too many requests"},
815
                JSStreamTransformInvalidDestination:          {Code: 400, ErrCode: 10156, Description: "stream transform: {err}"},
816
                JSStreamTransformInvalidSource:               {Code: 400, ErrCode: 10155, Description: "stream transform source: {err}"},
817
                JSStreamUpdateErrF:                           {Code: 500, ErrCode: 10069, Description: "{err}"},
818
                JSStreamWrongLastMsgIDErrF:                   {Code: 400, ErrCode: 10070, Description: "wrong last msg ID: {id}"},
819
                JSStreamWrongLastSequenceConstantErr:         {Code: 400, ErrCode: 10164, Description: "wrong last sequence"},
820
                JSStreamWrongLastSequenceErrF:                {Code: 400, ErrCode: 10071, Description: "wrong last sequence: {seq}"},
821
                JSTempStorageFailedErr:                       {Code: 500, ErrCode: 10072, Description: "JetStream unable to open temp storage for restore"},
822
                JSTemplateNameNotMatchSubjectErr:             {Code: 400, ErrCode: 10073, Description: "template name in subject does not match request"},
823
        }
824
        // ErrJetStreamNotClustered Deprecated by JSClusterNotActiveErr ApiError, use IsNatsError() for comparisons
825
        ErrJetStreamNotClustered = ApiErrors[JSClusterNotActiveErr]
826
        // ErrJetStreamNotAssigned Deprecated by JSClusterNotAssignedErr ApiError, use IsNatsError() for comparisons
827
        ErrJetStreamNotAssigned = ApiErrors[JSClusterNotAssignedErr]
828
        // ErrJetStreamNotLeader Deprecated by JSClusterNotLeaderErr ApiError, use IsNatsError() for comparisons
829
        ErrJetStreamNotLeader = ApiErrors[JSClusterNotLeaderErr]
830
        // ErrJetStreamConsumerAlreadyUsed Deprecated by JSConsumerNameExistErr ApiError, use IsNatsError() for comparisons
831
        ErrJetStreamConsumerAlreadyUsed = ApiErrors[JSConsumerNameExistErr]
832
        // ErrJetStreamResourcesExceeded Deprecated by JSInsufficientResourcesErr ApiError, use IsNatsError() for comparisons
833
        ErrJetStreamResourcesExceeded = ApiErrors[JSInsufficientResourcesErr]
834
        // ErrMemoryResourcesExceeded Deprecated by JSMemoryResourcesExceededErr ApiError, use IsNatsError() for comparisons
835
        ErrMemoryResourcesExceeded = ApiErrors[JSMemoryResourcesExceededErr]
836
        // ErrJetStreamNotEnabled Deprecated by JSNotEnabledErr ApiError, use IsNatsError() for comparisons
837
        ErrJetStreamNotEnabled = ApiErrors[JSNotEnabledErr]
838
        // ErrStorageResourcesExceeded Deprecated by JSStorageResourcesExceededErr ApiError, use IsNatsError() for comparisons
839
        ErrStorageResourcesExceeded = ApiErrors[JSStorageResourcesExceededErr]
840
        // ErrJetStreamStreamAlreadyUsed Deprecated by JSStreamNameExistErr ApiError, use IsNatsError() for comparisons
841
        ErrJetStreamStreamAlreadyUsed = ApiErrors[JSStreamNameExistErr]
842
        // ErrJetStreamStreamNotFound Deprecated by JSStreamNotFoundErr ApiError, use IsNatsError() for comparisons
843
        ErrJetStreamStreamNotFound = ApiErrors[JSStreamNotFoundErr]
844
        // ErrReplicasNotSupported Deprecated by JSStreamReplicasNotSupportedErr ApiError, use IsNatsError() for comparisons
845
        ErrReplicasNotSupported = ApiErrors[JSStreamReplicasNotSupportedErr]
846
)
847

848
// NewJSAccountResourcesExceededError creates a new JSAccountResourcesExceededErr error: "resource limits exceeded for account"
849
func NewJSAccountResourcesExceededError(opts ...ErrorOption) *ApiError {
20,059✔
850
        eopts := parseOpts(opts)
20,059✔
851
        if ae, ok := eopts.err.(*ApiError); ok {
20,059✔
852
                return ae
×
853
        }
×
854

855
        return ApiErrors[JSAccountResourcesExceededErr]
20,059✔
856
}
857

858
// NewJSAtomicPublishContainsDuplicateMessageError creates a new JSAtomicPublishContainsDuplicateMessageErr error: "atomic publish batch contains duplicate message id"
859
func NewJSAtomicPublishContainsDuplicateMessageError(opts ...ErrorOption) *ApiError {
22,015✔
860
        eopts := parseOpts(opts)
22,015✔
861
        if ae, ok := eopts.err.(*ApiError); ok {
22,015✔
862
                return ae
×
863
        }
×
864

865
        return ApiErrors[JSAtomicPublishContainsDuplicateMessageErr]
22,015✔
866
}
867

868
// NewJSAtomicPublishDisabledError creates a new JSAtomicPublishDisabledErr error: "atomic publish is disabled"
869
func NewJSAtomicPublishDisabledError(opts ...ErrorOption) *ApiError {
24✔
870
        eopts := parseOpts(opts)
24✔
871
        if ae, ok := eopts.err.(*ApiError); ok {
24✔
872
                return ae
×
873
        }
×
874

875
        return ApiErrors[JSAtomicPublishDisabledErr]
24✔
876
}
877

878
// NewJSAtomicPublishIncompleteBatchError creates a new JSAtomicPublishIncompleteBatchErr error: "atomic publish batch is incomplete"
879
func NewJSAtomicPublishIncompleteBatchError(opts ...ErrorOption) *ApiError {
62✔
880
        eopts := parseOpts(opts)
62✔
881
        if ae, ok := eopts.err.(*ApiError); ok {
62✔
882
                return ae
×
883
        }
×
884

885
        return ApiErrors[JSAtomicPublishIncompleteBatchErr]
62✔
886
}
887

888
// NewJSAtomicPublishInvalidBatchCommitError creates a new JSAtomicPublishInvalidBatchCommitErr error: "atomic publish batch commit is invalid"
889
func NewJSAtomicPublishInvalidBatchCommitError(opts ...ErrorOption) *ApiError {
6✔
890
        eopts := parseOpts(opts)
6✔
891
        if ae, ok := eopts.err.(*ApiError); ok {
6✔
892
                return ae
×
893
        }
×
894

895
        return ApiErrors[JSAtomicPublishInvalidBatchCommitErr]
6✔
896
}
897

898
// NewJSAtomicPublishInvalidBatchIDError creates a new JSAtomicPublishInvalidBatchIDErr error: "atomic publish batch ID is invalid"
899
func NewJSAtomicPublishInvalidBatchIDError(opts ...ErrorOption) *ApiError {
4✔
900
        eopts := parseOpts(opts)
4✔
901
        if ae, ok := eopts.err.(*ApiError); ok {
4✔
902
                return ae
×
903
        }
×
904

905
        return ApiErrors[JSAtomicPublishInvalidBatchIDErr]
4✔
906
}
907

908
// NewJSAtomicPublishMissingSeqError creates a new JSAtomicPublishMissingSeqErr error: "atomic publish sequence is missing"
909
func NewJSAtomicPublishMissingSeqError(opts ...ErrorOption) *ApiError {
24✔
910
        eopts := parseOpts(opts)
24✔
911
        if ae, ok := eopts.err.(*ApiError); ok {
24✔
912
                return ae
×
913
        }
×
914

915
        return ApiErrors[JSAtomicPublishMissingSeqErr]
24✔
916
}
917

918
// NewJSAtomicPublishTooLargeBatchError creates a new JSAtomicPublishTooLargeBatchErrF error: "atomic publish batch is too large: {size}"
919
func NewJSAtomicPublishTooLargeBatchError(size interface{}, opts ...ErrorOption) *ApiError {
10✔
920
        eopts := parseOpts(opts)
10✔
921
        if ae, ok := eopts.err.(*ApiError); ok {
10✔
922
                return ae
×
923
        }
×
924

925
        e := ApiErrors[JSAtomicPublishTooLargeBatchErrF]
10✔
926
        args := e.toReplacerArgs([]interface{}{"{size}", size})
10✔
927
        return &ApiError{
10✔
928
                Code:        e.Code,
10✔
929
                ErrCode:     e.ErrCode,
10✔
930
                Description: strings.NewReplacer(args...).Replace(e.Description),
10✔
931
        }
10✔
932
}
933

934
// NewJSAtomicPublishUnsupportedHeaderBatchError creates a new JSAtomicPublishUnsupportedHeaderBatchErr error: "atomic publish unsupported header used: {header}"
935
func NewJSAtomicPublishUnsupportedHeaderBatchError(header interface{}, opts ...ErrorOption) *ApiError {
4✔
936
        eopts := parseOpts(opts)
4✔
937
        if ae, ok := eopts.err.(*ApiError); ok {
4✔
938
                return ae
×
939
        }
×
940

941
        e := ApiErrors[JSAtomicPublishUnsupportedHeaderBatchErr]
4✔
942
        args := e.toReplacerArgs([]interface{}{"{header}", header})
4✔
943
        return &ApiError{
4✔
944
                Code:        e.Code,
4✔
945
                ErrCode:     e.ErrCode,
4✔
946
                Description: strings.NewReplacer(args...).Replace(e.Description),
4✔
947
        }
4✔
948
}
949

950
// NewJSBadRequestError creates a new JSBadRequestErr error: "bad request"
951
func NewJSBadRequestError(opts ...ErrorOption) *ApiError {
10✔
952
        eopts := parseOpts(opts)
10✔
953
        if ae, ok := eopts.err.(*ApiError); ok {
10✔
954
                return ae
×
955
        }
×
956

957
        return ApiErrors[JSBadRequestErr]
10✔
958
}
959

960
// NewJSClusterIncompleteError creates a new JSClusterIncompleteErr error: "incomplete results"
961
func NewJSClusterIncompleteError(opts ...ErrorOption) *ApiError {
×
962
        eopts := parseOpts(opts)
×
963
        if ae, ok := eopts.err.(*ApiError); ok {
×
964
                return ae
×
965
        }
×
966

967
        return ApiErrors[JSClusterIncompleteErr]
×
968
}
969

970
// NewJSClusterNoPeersError creates a new JSClusterNoPeersErrF error: "{err}"
971
func NewJSClusterNoPeersError(err error, opts ...ErrorOption) *ApiError {
59✔
972
        eopts := parseOpts(opts)
59✔
973
        if ae, ok := eopts.err.(*ApiError); ok {
59✔
974
                return ae
×
975
        }
×
976

977
        e := ApiErrors[JSClusterNoPeersErrF]
59✔
978
        args := e.toReplacerArgs([]interface{}{"{err}", err})
59✔
979
        return &ApiError{
59✔
980
                Code:        e.Code,
59✔
981
                ErrCode:     e.ErrCode,
59✔
982
                Description: strings.NewReplacer(args...).Replace(e.Description),
59✔
983
        }
59✔
984
}
985

986
// NewJSClusterNotActiveError creates a new JSClusterNotActiveErr error: "JetStream not in clustered mode"
987
func NewJSClusterNotActiveError(opts ...ErrorOption) *ApiError {
1✔
988
        eopts := parseOpts(opts)
1✔
989
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
990
                return ae
×
991
        }
×
992

993
        return ApiErrors[JSClusterNotActiveErr]
1✔
994
}
995

996
// NewJSClusterNotAssignedError creates a new JSClusterNotAssignedErr error: "JetStream cluster not assigned to this server"
997
func NewJSClusterNotAssignedError(opts ...ErrorOption) *ApiError {
1✔
998
        eopts := parseOpts(opts)
1✔
999
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
1000
                return ae
×
1001
        }
×
1002

1003
        return ApiErrors[JSClusterNotAssignedErr]
1✔
1004
}
1005

1006
// NewJSClusterNotAvailError creates a new JSClusterNotAvailErr error: "JetStream system temporarily unavailable"
1007
func NewJSClusterNotAvailError(opts ...ErrorOption) *ApiError {
13✔
1008
        eopts := parseOpts(opts)
13✔
1009
        if ae, ok := eopts.err.(*ApiError); ok {
13✔
1010
                return ae
×
1011
        }
×
1012

1013
        return ApiErrors[JSClusterNotAvailErr]
13✔
1014
}
1015

1016
// NewJSClusterNotLeaderError creates a new JSClusterNotLeaderErr error: "JetStream cluster can not handle request"
1017
func NewJSClusterNotLeaderError(opts ...ErrorOption) *ApiError {
770✔
1018
        eopts := parseOpts(opts)
770✔
1019
        if ae, ok := eopts.err.(*ApiError); ok {
770✔
1020
                return ae
×
1021
        }
×
1022

1023
        return ApiErrors[JSClusterNotLeaderErr]
770✔
1024
}
1025

1026
// NewJSClusterPeerNotMemberError creates a new JSClusterPeerNotMemberErr error: "peer not a member"
1027
func NewJSClusterPeerNotMemberError(opts ...ErrorOption) *ApiError {
1✔
1028
        eopts := parseOpts(opts)
1✔
1029
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
1030
                return ae
×
1031
        }
×
1032

1033
        return ApiErrors[JSClusterPeerNotMemberErr]
1✔
1034
}
1035

1036
// NewJSClusterRequiredError creates a new JSClusterRequiredErr error: "JetStream clustering support required"
1037
func NewJSClusterRequiredError(opts ...ErrorOption) *ApiError {
6✔
1038
        eopts := parseOpts(opts)
6✔
1039
        if ae, ok := eopts.err.(*ApiError); ok {
6✔
1040
                return ae
×
1041
        }
×
1042

1043
        return ApiErrors[JSClusterRequiredErr]
6✔
1044
}
1045

1046
// NewJSClusterServerMemberChangeInflightError creates a new JSClusterServerMemberChangeInflightErr error: "cluster member change is in progress"
1047
func NewJSClusterServerMemberChangeInflightError(opts ...ErrorOption) *ApiError {
6✔
1048
        eopts := parseOpts(opts)
6✔
1049
        if ae, ok := eopts.err.(*ApiError); ok {
6✔
1050
                return ae
×
1051
        }
×
1052

1053
        return ApiErrors[JSClusterServerMemberChangeInflightErr]
6✔
1054
}
1055

1056
// NewJSClusterServerNotMemberError creates a new JSClusterServerNotMemberErr error: "server is not a member of the cluster"
1057
func NewJSClusterServerNotMemberError(opts ...ErrorOption) *ApiError {
6✔
1058
        eopts := parseOpts(opts)
6✔
1059
        if ae, ok := eopts.err.(*ApiError); ok {
6✔
1060
                return ae
×
1061
        }
×
1062

1063
        return ApiErrors[JSClusterServerNotMemberErr]
6✔
1064
}
1065

1066
// NewJSClusterTagsError creates a new JSClusterTagsErr error: "tags placement not supported for operation"
1067
func NewJSClusterTagsError(opts ...ErrorOption) *ApiError {
×
1068
        eopts := parseOpts(opts)
×
1069
        if ae, ok := eopts.err.(*ApiError); ok {
×
1070
                return ae
×
1071
        }
×
1072

1073
        return ApiErrors[JSClusterTagsErr]
×
1074
}
1075

1076
// NewJSClusterUnSupportFeatureError creates a new JSClusterUnSupportFeatureErr error: "not currently supported in clustered mode"
1077
func NewJSClusterUnSupportFeatureError(opts ...ErrorOption) *ApiError {
×
1078
        eopts := parseOpts(opts)
×
1079
        if ae, ok := eopts.err.(*ApiError); ok {
×
1080
                return ae
×
1081
        }
×
1082

1083
        return ApiErrors[JSClusterUnSupportFeatureErr]
×
1084
}
1085

1086
// NewJSConsumerAckPolicyInvalidError creates a new JSConsumerAckPolicyInvalidErr error: "consumer ack policy invalid"
1087
func NewJSConsumerAckPolicyInvalidError(opts ...ErrorOption) *ApiError {
2✔
1088
        eopts := parseOpts(opts)
2✔
1089
        if ae, ok := eopts.err.(*ApiError); ok {
2✔
1090
                return ae
×
1091
        }
×
1092

1093
        return ApiErrors[JSConsumerAckPolicyInvalidErr]
2✔
1094
}
1095

1096
// NewJSConsumerAckWaitNegativeError creates a new JSConsumerAckWaitNegativeErr error: "consumer ack wait needs to be positive"
1097
func NewJSConsumerAckWaitNegativeError(opts ...ErrorOption) *ApiError {
2✔
1098
        eopts := parseOpts(opts)
2✔
1099
        if ae, ok := eopts.err.(*ApiError); ok {
2✔
1100
                return ae
×
1101
        }
×
1102

1103
        return ApiErrors[JSConsumerAckWaitNegativeErr]
2✔
1104
}
1105

1106
// NewJSConsumerAlreadyExistsError creates a new JSConsumerAlreadyExists error: "consumer already exists"
1107
func NewJSConsumerAlreadyExistsError(opts ...ErrorOption) *ApiError {
5✔
1108
        eopts := parseOpts(opts)
5✔
1109
        if ae, ok := eopts.err.(*ApiError); ok {
5✔
1110
                return ae
×
1111
        }
×
1112

1113
        return ApiErrors[JSConsumerAlreadyExists]
5✔
1114
}
1115

1116
// NewJSConsumerBackOffNegativeError creates a new JSConsumerBackOffNegativeErr error: "consumer backoff needs to be positive"
1117
func NewJSConsumerBackOffNegativeError(opts ...ErrorOption) *ApiError {
2✔
1118
        eopts := parseOpts(opts)
2✔
1119
        if ae, ok := eopts.err.(*ApiError); ok {
2✔
1120
                return ae
×
1121
        }
×
1122

1123
        return ApiErrors[JSConsumerBackOffNegativeErr]
2✔
1124
}
1125

1126
// NewJSConsumerBadDurableNameError creates a new JSConsumerBadDurableNameErr error: "durable name can not contain '.', '*', '>'"
1127
func NewJSConsumerBadDurableNameError(opts ...ErrorOption) *ApiError {
×
1128
        eopts := parseOpts(opts)
×
1129
        if ae, ok := eopts.err.(*ApiError); ok {
×
1130
                return ae
×
1131
        }
×
1132

1133
        return ApiErrors[JSConsumerBadDurableNameErr]
×
1134
}
1135

1136
// NewJSConsumerConfigRequiredError creates a new JSConsumerConfigRequiredErr error: "consumer config required"
1137
func NewJSConsumerConfigRequiredError(opts ...ErrorOption) *ApiError {
2✔
1138
        eopts := parseOpts(opts)
2✔
1139
        if ae, ok := eopts.err.(*ApiError); ok {
2✔
1140
                return ae
×
1141
        }
×
1142

1143
        return ApiErrors[JSConsumerConfigRequiredErr]
2✔
1144
}
1145

1146
// NewJSConsumerCreateDurableAndNameMismatchError creates a new JSConsumerCreateDurableAndNameMismatch error: "Consumer Durable and Name have to be equal if both are provided"
1147
func NewJSConsumerCreateDurableAndNameMismatchError(opts ...ErrorOption) *ApiError {
1✔
1148
        eopts := parseOpts(opts)
1✔
1149
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
1150
                return ae
×
1151
        }
×
1152

1153
        return ApiErrors[JSConsumerCreateDurableAndNameMismatch]
1✔
1154
}
1155

1156
// NewJSConsumerCreateError creates a new JSConsumerCreateErrF error: "{err}"
1157
func NewJSConsumerCreateError(err error, opts ...ErrorOption) *ApiError {
75✔
1158
        eopts := parseOpts(opts)
75✔
1159
        if ae, ok := eopts.err.(*ApiError); ok {
132✔
1160
                return ae
57✔
1161
        }
57✔
1162

1163
        e := ApiErrors[JSConsumerCreateErrF]
18✔
1164
        args := e.toReplacerArgs([]interface{}{"{err}", err})
18✔
1165
        return &ApiError{
18✔
1166
                Code:        e.Code,
18✔
1167
                ErrCode:     e.ErrCode,
18✔
1168
                Description: strings.NewReplacer(args...).Replace(e.Description),
18✔
1169
        }
18✔
1170
}
1171

1172
// NewJSConsumerCreateFilterSubjectMismatchError creates a new JSConsumerCreateFilterSubjectMismatchErr error: "Consumer create request did not match filtered subject from create subject"
1173
func NewJSConsumerCreateFilterSubjectMismatchError(opts ...ErrorOption) *ApiError {
2✔
1174
        eopts := parseOpts(opts)
2✔
1175
        if ae, ok := eopts.err.(*ApiError); ok {
2✔
1176
                return ae
×
1177
        }
×
1178

1179
        return ApiErrors[JSConsumerCreateFilterSubjectMismatchErr]
2✔
1180
}
1181

1182
// NewJSConsumerDeliverCycleError creates a new JSConsumerDeliverCycleErr error: "consumer deliver subject forms a cycle"
1183
func NewJSConsumerDeliverCycleError(opts ...ErrorOption) *ApiError {
4✔
1184
        eopts := parseOpts(opts)
4✔
1185
        if ae, ok := eopts.err.(*ApiError); ok {
4✔
1186
                return ae
×
1187
        }
×
1188

1189
        return ApiErrors[JSConsumerDeliverCycleErr]
4✔
1190
}
1191

1192
// NewJSConsumerDeliverToWildcardsError creates a new JSConsumerDeliverToWildcardsErr error: "consumer deliver subject has wildcards"
1193
func NewJSConsumerDeliverToWildcardsError(opts ...ErrorOption) *ApiError {
4✔
1194
        eopts := parseOpts(opts)
4✔
1195
        if ae, ok := eopts.err.(*ApiError); ok {
4✔
1196
                return ae
×
1197
        }
×
1198

1199
        return ApiErrors[JSConsumerDeliverToWildcardsErr]
4✔
1200
}
1201

1202
// NewJSConsumerDescriptionTooLongError creates a new JSConsumerDescriptionTooLongErrF error: "consumer description is too long, maximum allowed is {max}"
1203
func NewJSConsumerDescriptionTooLongError(max interface{}, opts ...ErrorOption) *ApiError {
1✔
1204
        eopts := parseOpts(opts)
1✔
1205
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
1206
                return ae
×
1207
        }
×
1208

1209
        e := ApiErrors[JSConsumerDescriptionTooLongErrF]
1✔
1210
        args := e.toReplacerArgs([]interface{}{"{max}", max})
1✔
1211
        return &ApiError{
1✔
1212
                Code:        e.Code,
1✔
1213
                ErrCode:     e.ErrCode,
1✔
1214
                Description: strings.NewReplacer(args...).Replace(e.Description),
1✔
1215
        }
1✔
1216
}
1217

1218
// NewJSConsumerDirectRequiresEphemeralError creates a new JSConsumerDirectRequiresEphemeralErr error: "consumer direct requires an ephemeral consumer"
1219
func NewJSConsumerDirectRequiresEphemeralError(opts ...ErrorOption) *ApiError {
×
1220
        eopts := parseOpts(opts)
×
1221
        if ae, ok := eopts.err.(*ApiError); ok {
×
1222
                return ae
×
1223
        }
×
1224

1225
        return ApiErrors[JSConsumerDirectRequiresEphemeralErr]
×
1226
}
1227

1228
// NewJSConsumerDirectRequiresPushError creates a new JSConsumerDirectRequiresPushErr error: "consumer direct requires a push based consumer"
1229
func NewJSConsumerDirectRequiresPushError(opts ...ErrorOption) *ApiError {
×
1230
        eopts := parseOpts(opts)
×
1231
        if ae, ok := eopts.err.(*ApiError); ok {
×
1232
                return ae
×
1233
        }
×
1234

1235
        return ApiErrors[JSConsumerDirectRequiresPushErr]
×
1236
}
1237

1238
// NewJSConsumerDoesNotExistError creates a new JSConsumerDoesNotExist error: "consumer does not exist"
1239
func NewJSConsumerDoesNotExistError(opts ...ErrorOption) *ApiError {
3✔
1240
        eopts := parseOpts(opts)
3✔
1241
        if ae, ok := eopts.err.(*ApiError); ok {
3✔
1242
                return ae
×
1243
        }
×
1244

1245
        return ApiErrors[JSConsumerDoesNotExist]
3✔
1246
}
1247

1248
// NewJSConsumerDuplicateFilterSubjectsError creates a new JSConsumerDuplicateFilterSubjects error: "consumer cannot have both FilterSubject and FilterSubjects specified"
1249
func NewJSConsumerDuplicateFilterSubjectsError(opts ...ErrorOption) *ApiError {
1✔
1250
        eopts := parseOpts(opts)
1✔
1251
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
1252
                return ae
×
1253
        }
×
1254

1255
        return ApiErrors[JSConsumerDuplicateFilterSubjects]
1✔
1256
}
1257

1258
// NewJSConsumerDurableNameNotInSubjectError creates a new JSConsumerDurableNameNotInSubjectErr error: "consumer expected to be durable but no durable name set in subject"
1259
func NewJSConsumerDurableNameNotInSubjectError(opts ...ErrorOption) *ApiError {
×
1260
        eopts := parseOpts(opts)
×
1261
        if ae, ok := eopts.err.(*ApiError); ok {
×
1262
                return ae
×
1263
        }
×
1264

1265
        return ApiErrors[JSConsumerDurableNameNotInSubjectErr]
×
1266
}
1267

1268
// NewJSConsumerDurableNameNotMatchSubjectError creates a new JSConsumerDurableNameNotMatchSubjectErr error: "consumer name in subject does not match durable name in request"
1269
func NewJSConsumerDurableNameNotMatchSubjectError(opts ...ErrorOption) *ApiError {
×
1270
        eopts := parseOpts(opts)
×
1271
        if ae, ok := eopts.err.(*ApiError); ok {
×
1272
                return ae
×
1273
        }
×
1274

1275
        return ApiErrors[JSConsumerDurableNameNotMatchSubjectErr]
×
1276
}
1277

1278
// NewJSConsumerDurableNameNotSetError creates a new JSConsumerDurableNameNotSetErr error: "consumer expected to be durable but a durable name was not set"
1279
func NewJSConsumerDurableNameNotSetError(opts ...ErrorOption) *ApiError {
1✔
1280
        eopts := parseOpts(opts)
1✔
1281
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
1282
                return ae
×
1283
        }
×
1284

1285
        return ApiErrors[JSConsumerDurableNameNotSetErr]
1✔
1286
}
1287

1288
// NewJSConsumerEmptyFilterError creates a new JSConsumerEmptyFilter error: "consumer filter in FilterSubjects cannot be empty"
1289
func NewJSConsumerEmptyFilterError(opts ...ErrorOption) *ApiError {
1✔
1290
        eopts := parseOpts(opts)
1✔
1291
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
1292
                return ae
×
1293
        }
×
1294

1295
        return ApiErrors[JSConsumerEmptyFilter]
1✔
1296
}
1297

1298
// NewJSConsumerEmptyGroupNameError creates a new JSConsumerEmptyGroupName error: "Group name cannot be an empty string"
1299
func NewJSConsumerEmptyGroupNameError(opts ...ErrorOption) *ApiError {
4✔
1300
        eopts := parseOpts(opts)
4✔
1301
        if ae, ok := eopts.err.(*ApiError); ok {
4✔
1302
                return ae
×
1303
        }
×
1304

1305
        return ApiErrors[JSConsumerEmptyGroupName]
4✔
1306
}
1307

1308
// NewJSConsumerEphemeralWithDurableInSubjectError creates a new JSConsumerEphemeralWithDurableInSubjectErr error: "consumer expected to be ephemeral but detected a durable name set in subject"
1309
func NewJSConsumerEphemeralWithDurableInSubjectError(opts ...ErrorOption) *ApiError {
×
1310
        eopts := parseOpts(opts)
×
1311
        if ae, ok := eopts.err.(*ApiError); ok {
×
1312
                return ae
×
1313
        }
×
1314

1315
        return ApiErrors[JSConsumerEphemeralWithDurableInSubjectErr]
×
1316
}
1317

1318
// NewJSConsumerEphemeralWithDurableNameError creates a new JSConsumerEphemeralWithDurableNameErr error: "consumer expected to be ephemeral but a durable name was set in request"
1319
func NewJSConsumerEphemeralWithDurableNameError(opts ...ErrorOption) *ApiError {
3✔
1320
        eopts := parseOpts(opts)
3✔
1321
        if ae, ok := eopts.err.(*ApiError); ok {
3✔
1322
                return ae
×
1323
        }
×
1324

1325
        return ApiErrors[JSConsumerEphemeralWithDurableNameErr]
3✔
1326
}
1327

1328
// NewJSConsumerExistingActiveError creates a new JSConsumerExistingActiveErr error: "consumer already exists and is still active"
1329
func NewJSConsumerExistingActiveError(opts ...ErrorOption) *ApiError {
×
1330
        eopts := parseOpts(opts)
×
1331
        if ae, ok := eopts.err.(*ApiError); ok {
×
1332
                return ae
×
1333
        }
×
1334

1335
        return ApiErrors[JSConsumerExistingActiveErr]
×
1336
}
1337

1338
// NewJSConsumerFCRequiresPushError creates a new JSConsumerFCRequiresPushErr error: "consumer flow control requires a push based consumer"
1339
func NewJSConsumerFCRequiresPushError(opts ...ErrorOption) *ApiError {
×
1340
        eopts := parseOpts(opts)
×
1341
        if ae, ok := eopts.err.(*ApiError); ok {
×
1342
                return ae
×
1343
        }
×
1344

1345
        return ApiErrors[JSConsumerFCRequiresPushErr]
×
1346
}
1347

1348
// NewJSConsumerFilterNotSubsetError creates a new JSConsumerFilterNotSubsetErr error: "consumer filter subject is not a valid subset of the interest subjects"
1349
func NewJSConsumerFilterNotSubsetError(opts ...ErrorOption) *ApiError {
×
1350
        eopts := parseOpts(opts)
×
1351
        if ae, ok := eopts.err.(*ApiError); ok {
×
1352
                return ae
×
1353
        }
×
1354

1355
        return ApiErrors[JSConsumerFilterNotSubsetErr]
×
1356
}
1357

1358
// NewJSConsumerHBRequiresPushError creates a new JSConsumerHBRequiresPushErr error: "consumer idle heartbeat requires a push based consumer"
1359
func NewJSConsumerHBRequiresPushError(opts ...ErrorOption) *ApiError {
×
1360
        eopts := parseOpts(opts)
×
1361
        if ae, ok := eopts.err.(*ApiError); ok {
×
1362
                return ae
×
1363
        }
×
1364

1365
        return ApiErrors[JSConsumerHBRequiresPushErr]
×
1366
}
1367

1368
// NewJSConsumerInactiveThresholdExcessError creates a new JSConsumerInactiveThresholdExcess error: "consumer inactive threshold exceeds system limit of {limit}"
1369
func NewJSConsumerInactiveThresholdExcessError(limit interface{}, opts ...ErrorOption) *ApiError {
2✔
1370
        eopts := parseOpts(opts)
2✔
1371
        if ae, ok := eopts.err.(*ApiError); ok {
2✔
1372
                return ae
×
1373
        }
×
1374

1375
        e := ApiErrors[JSConsumerInactiveThresholdExcess]
2✔
1376
        args := e.toReplacerArgs([]interface{}{"{limit}", limit})
2✔
1377
        return &ApiError{
2✔
1378
                Code:        e.Code,
2✔
1379
                ErrCode:     e.ErrCode,
2✔
1380
                Description: strings.NewReplacer(args...).Replace(e.Description),
2✔
1381
        }
2✔
1382
}
1383

1384
// NewJSConsumerInvalidDeliverSubjectError creates a new JSConsumerInvalidDeliverSubject error: "invalid push consumer deliver subject"
1385
func NewJSConsumerInvalidDeliverSubjectError(opts ...ErrorOption) *ApiError {
2✔
1386
        eopts := parseOpts(opts)
2✔
1387
        if ae, ok := eopts.err.(*ApiError); ok {
2✔
1388
                return ae
×
1389
        }
×
1390

1391
        return ApiErrors[JSConsumerInvalidDeliverSubject]
2✔
1392
}
1393

1394
// NewJSConsumerInvalidGroupNameError creates a new JSConsumerInvalidGroupNameErr error: "Valid priority group name must match A-Z, a-z, 0-9, -_/=)+ and may not exceed 16 characters"
1395
func NewJSConsumerInvalidGroupNameError(opts ...ErrorOption) *ApiError {
2✔
1396
        eopts := parseOpts(opts)
2✔
1397
        if ae, ok := eopts.err.(*ApiError); ok {
2✔
1398
                return ae
×
1399
        }
×
1400

1401
        return ApiErrors[JSConsumerInvalidGroupNameErr]
2✔
1402
}
1403

1404
// NewJSConsumerInvalidPolicyError creates a new JSConsumerInvalidPolicyErrF error: "{err}"
1405
func NewJSConsumerInvalidPolicyError(err error, opts ...ErrorOption) *ApiError {
10✔
1406
        eopts := parseOpts(opts)
10✔
1407
        if ae, ok := eopts.err.(*ApiError); ok {
10✔
1408
                return ae
×
1409
        }
×
1410

1411
        e := ApiErrors[JSConsumerInvalidPolicyErrF]
10✔
1412
        args := e.toReplacerArgs([]interface{}{"{err}", err})
10✔
1413
        return &ApiError{
10✔
1414
                Code:        e.Code,
10✔
1415
                ErrCode:     e.ErrCode,
10✔
1416
                Description: strings.NewReplacer(args...).Replace(e.Description),
10✔
1417
        }
10✔
1418
}
1419

1420
// NewJSConsumerInvalidPriorityGroupError creates a new JSConsumerInvalidPriorityGroupErr error: "Provided priority group does not exist for this consumer"
1421
func NewJSConsumerInvalidPriorityGroupError(opts ...ErrorOption) *ApiError {
2✔
1422
        eopts := parseOpts(opts)
2✔
1423
        if ae, ok := eopts.err.(*ApiError); ok {
2✔
1424
                return ae
×
1425
        }
×
1426

1427
        return ApiErrors[JSConsumerInvalidPriorityGroupErr]
2✔
1428
}
1429

1430
// NewJSConsumerInvalidResetError creates a new JSConsumerInvalidResetErr error: "invalid reset: {err}"
1431
func NewJSConsumerInvalidResetError(err error, opts ...ErrorOption) *ApiError {
4✔
1432
        eopts := parseOpts(opts)
4✔
1433
        if ae, ok := eopts.err.(*ApiError); ok {
4✔
1434
                return ae
×
1435
        }
×
1436

1437
        e := ApiErrors[JSConsumerInvalidResetErr]
4✔
1438
        args := e.toReplacerArgs([]interface{}{"{err}", err})
4✔
1439
        return &ApiError{
4✔
1440
                Code:        e.Code,
4✔
1441
                ErrCode:     e.ErrCode,
4✔
1442
                Description: strings.NewReplacer(args...).Replace(e.Description),
4✔
1443
        }
4✔
1444
}
1445

1446
// NewJSConsumerInvalidSamplingError creates a new JSConsumerInvalidSamplingErrF error: "failed to parse consumer sampling configuration: {err}"
1447
func NewJSConsumerInvalidSamplingError(err error, opts ...ErrorOption) *ApiError {
×
1448
        eopts := parseOpts(opts)
×
1449
        if ae, ok := eopts.err.(*ApiError); ok {
×
1450
                return ae
×
1451
        }
×
1452

1453
        e := ApiErrors[JSConsumerInvalidSamplingErrF]
×
1454
        args := e.toReplacerArgs([]interface{}{"{err}", err})
×
1455
        return &ApiError{
×
1456
                Code:        e.Code,
×
1457
                ErrCode:     e.ErrCode,
×
1458
                Description: strings.NewReplacer(args...).Replace(e.Description),
×
1459
        }
×
1460
}
1461

1462
// NewJSConsumerMaxDeliverBackoffError creates a new JSConsumerMaxDeliverBackoffErr error: "max deliver is required to be > length of backoff values"
1463
func NewJSConsumerMaxDeliverBackoffError(opts ...ErrorOption) *ApiError {
3✔
1464
        eopts := parseOpts(opts)
3✔
1465
        if ae, ok := eopts.err.(*ApiError); ok {
3✔
1466
                return ae
×
1467
        }
×
1468

1469
        return ApiErrors[JSConsumerMaxDeliverBackoffErr]
3✔
1470
}
1471

1472
// NewJSConsumerMaxPendingAckExcessError creates a new JSConsumerMaxPendingAckExcessErrF error: "consumer max ack pending exceeds system limit of {limit}"
1473
func NewJSConsumerMaxPendingAckExcessError(limit interface{}, opts ...ErrorOption) *ApiError {
12✔
1474
        eopts := parseOpts(opts)
12✔
1475
        if ae, ok := eopts.err.(*ApiError); ok {
12✔
1476
                return ae
×
1477
        }
×
1478

1479
        e := ApiErrors[JSConsumerMaxPendingAckExcessErrF]
12✔
1480
        args := e.toReplacerArgs([]interface{}{"{limit}", limit})
12✔
1481
        return &ApiError{
12✔
1482
                Code:        e.Code,
12✔
1483
                ErrCode:     e.ErrCode,
12✔
1484
                Description: strings.NewReplacer(args...).Replace(e.Description),
12✔
1485
        }
12✔
1486
}
1487

1488
// NewJSConsumerMaxPendingAckPolicyRequiredError creates a new JSConsumerMaxPendingAckPolicyRequiredErr error: "consumer requires ack policy for max ack pending"
1489
func NewJSConsumerMaxPendingAckPolicyRequiredError(opts ...ErrorOption) *ApiError {
2✔
1490
        eopts := parseOpts(opts)
2✔
1491
        if ae, ok := eopts.err.(*ApiError); ok {
2✔
1492
                return ae
×
1493
        }
×
1494

1495
        return ApiErrors[JSConsumerMaxPendingAckPolicyRequiredErr]
2✔
1496
}
1497

1498
// NewJSConsumerMaxRequestBatchExceededError creates a new JSConsumerMaxRequestBatchExceededF error: "consumer max request batch exceeds server limit of {limit}"
1499
func NewJSConsumerMaxRequestBatchExceededError(limit interface{}, opts ...ErrorOption) *ApiError {
4✔
1500
        eopts := parseOpts(opts)
4✔
1501
        if ae, ok := eopts.err.(*ApiError); ok {
4✔
1502
                return ae
×
1503
        }
×
1504

1505
        e := ApiErrors[JSConsumerMaxRequestBatchExceededF]
4✔
1506
        args := e.toReplacerArgs([]interface{}{"{limit}", limit})
4✔
1507
        return &ApiError{
4✔
1508
                Code:        e.Code,
4✔
1509
                ErrCode:     e.ErrCode,
4✔
1510
                Description: strings.NewReplacer(args...).Replace(e.Description),
4✔
1511
        }
4✔
1512
}
1513

1514
// NewJSConsumerMaxRequestBatchNegativeError creates a new JSConsumerMaxRequestBatchNegativeErr error: "consumer max request batch needs to be > 0"
1515
func NewJSConsumerMaxRequestBatchNegativeError(opts ...ErrorOption) *ApiError {
×
1516
        eopts := parseOpts(opts)
×
1517
        if ae, ok := eopts.err.(*ApiError); ok {
×
1518
                return ae
×
1519
        }
×
1520

1521
        return ApiErrors[JSConsumerMaxRequestBatchNegativeErr]
×
1522
}
1523

1524
// NewJSConsumerMaxRequestExpiresTooSmallError creates a new JSConsumerMaxRequestExpiresTooSmall error: "consumer max request expires needs to be >= 1ms"
1525
func NewJSConsumerMaxRequestExpiresTooSmallError(opts ...ErrorOption) *ApiError {
×
1526
        eopts := parseOpts(opts)
×
1527
        if ae, ok := eopts.err.(*ApiError); ok {
×
1528
                return ae
×
1529
        }
×
1530

1531
        return ApiErrors[JSConsumerMaxRequestExpiresTooSmall]
×
1532
}
1533

1534
// NewJSConsumerMaxWaitingNegativeError creates a new JSConsumerMaxWaitingNegativeErr error: "consumer max waiting needs to be positive"
1535
func NewJSConsumerMaxWaitingNegativeError(opts ...ErrorOption) *ApiError {
×
1536
        eopts := parseOpts(opts)
×
1537
        if ae, ok := eopts.err.(*ApiError); ok {
×
1538
                return ae
×
1539
        }
×
1540

1541
        return ApiErrors[JSConsumerMaxWaitingNegativeErr]
×
1542
}
1543

1544
// NewJSConsumerMetadataLengthError creates a new JSConsumerMetadataLengthErrF error: "consumer metadata exceeds maximum size of {limit}"
1545
func NewJSConsumerMetadataLengthError(limit interface{}, opts ...ErrorOption) *ApiError {
1✔
1546
        eopts := parseOpts(opts)
1✔
1547
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
1548
                return ae
×
1549
        }
×
1550

1551
        e := ApiErrors[JSConsumerMetadataLengthErrF]
1✔
1552
        args := e.toReplacerArgs([]interface{}{"{limit}", limit})
1✔
1553
        return &ApiError{
1✔
1554
                Code:        e.Code,
1✔
1555
                ErrCode:     e.ErrCode,
1✔
1556
                Description: strings.NewReplacer(args...).Replace(e.Description),
1✔
1557
        }
1✔
1558
}
1559

1560
// NewJSConsumerMultipleFiltersNotAllowedError creates a new JSConsumerMultipleFiltersNotAllowed error: "consumer with multiple subject filters cannot use subject based API"
1561
func NewJSConsumerMultipleFiltersNotAllowedError(opts ...ErrorOption) *ApiError {
1✔
1562
        eopts := parseOpts(opts)
1✔
1563
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
1564
                return ae
×
1565
        }
×
1566

1567
        return ApiErrors[JSConsumerMultipleFiltersNotAllowed]
1✔
1568
}
1569

1570
// NewJSConsumerNameContainsPathSeparatorsError creates a new JSConsumerNameContainsPathSeparatorsErr error: "Consumer name can not contain path separators"
1571
func NewJSConsumerNameContainsPathSeparatorsError(opts ...ErrorOption) *ApiError {
8✔
1572
        eopts := parseOpts(opts)
8✔
1573
        if ae, ok := eopts.err.(*ApiError); ok {
8✔
1574
                return ae
×
1575
        }
×
1576

1577
        return ApiErrors[JSConsumerNameContainsPathSeparatorsErr]
8✔
1578
}
1579

1580
// NewJSConsumerNameExistError creates a new JSConsumerNameExistErr error: "consumer name already in use"
1581
func NewJSConsumerNameExistError(opts ...ErrorOption) *ApiError {
2✔
1582
        eopts := parseOpts(opts)
2✔
1583
        if ae, ok := eopts.err.(*ApiError); ok {
2✔
1584
                return ae
×
1585
        }
×
1586

1587
        return ApiErrors[JSConsumerNameExistErr]
2✔
1588
}
1589

1590
// NewJSConsumerNameTooLongError creates a new JSConsumerNameTooLongErrF error: "consumer name is too long, maximum allowed is {max}"
1591
func NewJSConsumerNameTooLongError(max interface{}, opts ...ErrorOption) *ApiError {
×
1592
        eopts := parseOpts(opts)
×
1593
        if ae, ok := eopts.err.(*ApiError); ok {
×
1594
                return ae
×
1595
        }
×
1596

1597
        e := ApiErrors[JSConsumerNameTooLongErrF]
×
1598
        args := e.toReplacerArgs([]interface{}{"{max}", max})
×
1599
        return &ApiError{
×
1600
                Code:        e.Code,
×
1601
                ErrCode:     e.ErrCode,
×
1602
                Description: strings.NewReplacer(args...).Replace(e.Description),
×
1603
        }
×
1604
}
1605

1606
// NewJSConsumerNotFoundError creates a new JSConsumerNotFoundErr error: "consumer not found"
1607
func NewJSConsumerNotFoundError(opts ...ErrorOption) *ApiError {
2,851✔
1608
        eopts := parseOpts(opts)
2,851✔
1609
        if ae, ok := eopts.err.(*ApiError); ok {
2,851✔
1610
                return ae
×
1611
        }
×
1612

1613
        return ApiErrors[JSConsumerNotFoundErr]
2,851✔
1614
}
1615

1616
// NewJSConsumerOfflineError creates a new JSConsumerOfflineErr error: "consumer is offline"
1617
func NewJSConsumerOfflineError(opts ...ErrorOption) *ApiError {
6✔
1618
        eopts := parseOpts(opts)
6✔
1619
        if ae, ok := eopts.err.(*ApiError); ok {
6✔
1620
                return ae
×
1621
        }
×
1622

1623
        return ApiErrors[JSConsumerOfflineErr]
6✔
1624
}
1625

1626
// NewJSConsumerOfflineReasonError creates a new JSConsumerOfflineReasonErrF error: "consumer is offline: {err}"
1627
func NewJSConsumerOfflineReasonError(err error, opts ...ErrorOption) *ApiError {
24✔
1628
        eopts := parseOpts(opts)
24✔
1629
        if ae, ok := eopts.err.(*ApiError); ok {
24✔
1630
                return ae
×
1631
        }
×
1632

1633
        e := ApiErrors[JSConsumerOfflineReasonErrF]
24✔
1634
        args := e.toReplacerArgs([]interface{}{"{err}", err})
24✔
1635
        return &ApiError{
24✔
1636
                Code:        e.Code,
24✔
1637
                ErrCode:     e.ErrCode,
24✔
1638
                Description: strings.NewReplacer(args...).Replace(e.Description),
24✔
1639
        }
24✔
1640
}
1641

1642
// NewJSConsumerOnMappedError creates a new JSConsumerOnMappedErr error: "consumer direct on a mapped consumer"
1643
func NewJSConsumerOnMappedError(opts ...ErrorOption) *ApiError {
×
1644
        eopts := parseOpts(opts)
×
1645
        if ae, ok := eopts.err.(*ApiError); ok {
×
1646
                return ae
×
1647
        }
×
1648

1649
        return ApiErrors[JSConsumerOnMappedErr]
×
1650
}
1651

1652
// NewJSConsumerOverlappingSubjectFiltersError creates a new JSConsumerOverlappingSubjectFilters error: "consumer subject filters cannot overlap"
1653
func NewJSConsumerOverlappingSubjectFiltersError(opts ...ErrorOption) *ApiError {
3✔
1654
        eopts := parseOpts(opts)
3✔
1655
        if ae, ok := eopts.err.(*ApiError); ok {
3✔
1656
                return ae
×
1657
        }
×
1658

1659
        return ApiErrors[JSConsumerOverlappingSubjectFilters]
3✔
1660
}
1661

1662
// NewJSConsumerPinnedTTLWithoutPriorityPolicyNoneError creates a new JSConsumerPinnedTTLWithoutPriorityPolicyNone error: "PinnedTTL cannot be set when PriorityPolicy is none"
1663
func NewJSConsumerPinnedTTLWithoutPriorityPolicyNoneError(opts ...ErrorOption) *ApiError {
1✔
1664
        eopts := parseOpts(opts)
1✔
1665
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
1666
                return ae
×
1667
        }
×
1668

1669
        return ApiErrors[JSConsumerPinnedTTLWithoutPriorityPolicyNone]
1✔
1670
}
1671

1672
// NewJSConsumerPriorityGroupWithPolicyNoneError creates a new JSConsumerPriorityGroupWithPolicyNone error: "consumer can not have priority groups when policy is none"
1673
func NewJSConsumerPriorityGroupWithPolicyNoneError(opts ...ErrorOption) *ApiError {
1✔
1674
        eopts := parseOpts(opts)
1✔
1675
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
1676
                return ae
×
1677
        }
×
1678

1679
        return ApiErrors[JSConsumerPriorityGroupWithPolicyNone]
1✔
1680
}
1681

1682
// NewJSConsumerPriorityPolicyWithoutGroupError creates a new JSConsumerPriorityPolicyWithoutGroup error: "Setting PriorityPolicy requires at least one PriorityGroup to be set"
1683
func NewJSConsumerPriorityPolicyWithoutGroupError(opts ...ErrorOption) *ApiError {
4✔
1684
        eopts := parseOpts(opts)
4✔
1685
        if ae, ok := eopts.err.(*ApiError); ok {
4✔
1686
                return ae
×
1687
        }
×
1688

1689
        return ApiErrors[JSConsumerPriorityPolicyWithoutGroup]
4✔
1690
}
1691

1692
// NewJSConsumerPullNotDurableError creates a new JSConsumerPullNotDurableErr error: "consumer in pull mode requires a durable name"
1693
func NewJSConsumerPullNotDurableError(opts ...ErrorOption) *ApiError {
×
1694
        eopts := parseOpts(opts)
×
1695
        if ae, ok := eopts.err.(*ApiError); ok {
×
1696
                return ae
×
1697
        }
×
1698

1699
        return ApiErrors[JSConsumerPullNotDurableErr]
×
1700
}
1701

1702
// NewJSConsumerPullRequiresAckError creates a new JSConsumerPullRequiresAckErr error: "consumer in pull mode requires explicit ack policy on workqueue stream"
1703
func NewJSConsumerPullRequiresAckError(opts ...ErrorOption) *ApiError {
6✔
1704
        eopts := parseOpts(opts)
6✔
1705
        if ae, ok := eopts.err.(*ApiError); ok {
6✔
1706
                return ae
×
1707
        }
×
1708

1709
        return ApiErrors[JSConsumerPullRequiresAckErr]
6✔
1710
}
1711

1712
// NewJSConsumerPullWithRateLimitError creates a new JSConsumerPullWithRateLimitErr error: "consumer in pull mode can not have rate limit set"
1713
func NewJSConsumerPullWithRateLimitError(opts ...ErrorOption) *ApiError {
1✔
1714
        eopts := parseOpts(opts)
1✔
1715
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
1716
                return ae
×
1717
        }
×
1718

1719
        return ApiErrors[JSConsumerPullWithRateLimitErr]
1✔
1720
}
1721

1722
// NewJSConsumerPushMaxWaitingError creates a new JSConsumerPushMaxWaitingErr error: "consumer in push mode can not set max waiting"
1723
func NewJSConsumerPushMaxWaitingError(opts ...ErrorOption) *ApiError {
3✔
1724
        eopts := parseOpts(opts)
3✔
1725
        if ae, ok := eopts.err.(*ApiError); ok {
3✔
1726
                return ae
×
1727
        }
×
1728

1729
        return ApiErrors[JSConsumerPushMaxWaitingErr]
3✔
1730
}
1731

1732
// NewJSConsumerPushWithPriorityGroupError creates a new JSConsumerPushWithPriorityGroupErr error: "priority groups can not be used with push consumers"
1733
func NewJSConsumerPushWithPriorityGroupError(opts ...ErrorOption) *ApiError {
1✔
1734
        eopts := parseOpts(opts)
1✔
1735
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
1736
                return ae
×
1737
        }
×
1738

1739
        return ApiErrors[JSConsumerPushWithPriorityGroupErr]
1✔
1740
}
1741

1742
// NewJSConsumerReplacementWithDifferentNameError creates a new JSConsumerReplacementWithDifferentNameErr error: "consumer replacement durable config not the same"
1743
func NewJSConsumerReplacementWithDifferentNameError(opts ...ErrorOption) *ApiError {
×
1744
        eopts := parseOpts(opts)
×
1745
        if ae, ok := eopts.err.(*ApiError); ok {
×
1746
                return ae
×
1747
        }
×
1748

1749
        return ApiErrors[JSConsumerReplacementWithDifferentNameErr]
×
1750
}
1751

1752
// NewJSConsumerReplayPolicyInvalidError creates a new JSConsumerReplayPolicyInvalidErr error: "consumer replay policy invalid"
1753
func NewJSConsumerReplayPolicyInvalidError(opts ...ErrorOption) *ApiError {
2✔
1754
        eopts := parseOpts(opts)
2✔
1755
        if ae, ok := eopts.err.(*ApiError); ok {
2✔
1756
                return ae
×
1757
        }
×
1758

1759
        return ApiErrors[JSConsumerReplayPolicyInvalidErr]
2✔
1760
}
1761

1762
// NewJSConsumerReplicasExceedsStreamError creates a new JSConsumerReplicasExceedsStream error: "consumer config replica count exceeds parent stream"
1763
func NewJSConsumerReplicasExceedsStreamError(opts ...ErrorOption) *ApiError {
1✔
1764
        eopts := parseOpts(opts)
1✔
1765
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
1766
                return ae
×
1767
        }
×
1768

1769
        return ApiErrors[JSConsumerReplicasExceedsStream]
1✔
1770
}
1771

1772
// NewJSConsumerReplicasShouldMatchStreamError creates a new JSConsumerReplicasShouldMatchStream error: "consumer config replicas must match interest retention stream's replicas"
1773
func NewJSConsumerReplicasShouldMatchStreamError(opts ...ErrorOption) *ApiError {
2✔
1774
        eopts := parseOpts(opts)
2✔
1775
        if ae, ok := eopts.err.(*ApiError); ok {
2✔
1776
                return ae
×
1777
        }
×
1778

1779
        return ApiErrors[JSConsumerReplicasShouldMatchStream]
2✔
1780
}
1781

1782
// NewJSConsumerSmallHeartbeatError creates a new JSConsumerSmallHeartbeatErr error: "consumer idle heartbeat needs to be >= 100ms"
1783
func NewJSConsumerSmallHeartbeatError(opts ...ErrorOption) *ApiError {
1✔
1784
        eopts := parseOpts(opts)
1✔
1785
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
1786
                return ae
×
1787
        }
×
1788

1789
        return ApiErrors[JSConsumerSmallHeartbeatErr]
1✔
1790
}
1791

1792
// NewJSConsumerStoreFailedError creates a new JSConsumerStoreFailedErrF error: "error creating store for consumer: {err}"
1793
func NewJSConsumerStoreFailedError(err error, opts ...ErrorOption) *ApiError {
9✔
1794
        eopts := parseOpts(opts)
9✔
1795
        if ae, ok := eopts.err.(*ApiError); ok {
9✔
1796
                return ae
×
1797
        }
×
1798

1799
        e := ApiErrors[JSConsumerStoreFailedErrF]
9✔
1800
        args := e.toReplacerArgs([]interface{}{"{err}", err})
9✔
1801
        return &ApiError{
9✔
1802
                Code:        e.Code,
9✔
1803
                ErrCode:     e.ErrCode,
9✔
1804
                Description: strings.NewReplacer(args...).Replace(e.Description),
9✔
1805
        }
9✔
1806
}
1807

1808
// NewJSConsumerWQConsumerNotDeliverAllError creates a new JSConsumerWQConsumerNotDeliverAllErr error: "consumer must be deliver all on workqueue stream"
1809
func NewJSConsumerWQConsumerNotDeliverAllError(opts ...ErrorOption) *ApiError {
×
1810
        eopts := parseOpts(opts)
×
1811
        if ae, ok := eopts.err.(*ApiError); ok {
×
1812
                return ae
×
1813
        }
×
1814

1815
        return ApiErrors[JSConsumerWQConsumerNotDeliverAllErr]
×
1816
}
1817

1818
// NewJSConsumerWQConsumerNotUniqueError creates a new JSConsumerWQConsumerNotUniqueErr error: "filtered consumer not unique on workqueue stream"
1819
func NewJSConsumerWQConsumerNotUniqueError(opts ...ErrorOption) *ApiError {
11✔
1820
        eopts := parseOpts(opts)
11✔
1821
        if ae, ok := eopts.err.(*ApiError); ok {
11✔
1822
                return ae
×
1823
        }
×
1824

1825
        return ApiErrors[JSConsumerWQConsumerNotUniqueErr]
11✔
1826
}
1827

1828
// NewJSConsumerWQMultipleUnfilteredError creates a new JSConsumerWQMultipleUnfilteredErr error: "multiple non-filtered consumers not allowed on workqueue stream"
1829
func NewJSConsumerWQMultipleUnfilteredError(opts ...ErrorOption) *ApiError {
2✔
1830
        eopts := parseOpts(opts)
2✔
1831
        if ae, ok := eopts.err.(*ApiError); ok {
2✔
1832
                return ae
×
1833
        }
×
1834

1835
        return ApiErrors[JSConsumerWQMultipleUnfilteredErr]
2✔
1836
}
1837

1838
// NewJSConsumerWQRequiresExplicitAckError creates a new JSConsumerWQRequiresExplicitAckErr error: "workqueue stream requires explicit ack"
1839
func NewJSConsumerWQRequiresExplicitAckError(opts ...ErrorOption) *ApiError {
×
1840
        eopts := parseOpts(opts)
×
1841
        if ae, ok := eopts.err.(*ApiError); ok {
×
1842
                return ae
×
1843
        }
×
1844

1845
        return ApiErrors[JSConsumerWQRequiresExplicitAckErr]
×
1846
}
1847

1848
// NewJSConsumerWithFlowControlNeedsHeartbeatsError creates a new JSConsumerWithFlowControlNeedsHeartbeats error: "consumer with flow control also needs heartbeats"
1849
func NewJSConsumerWithFlowControlNeedsHeartbeatsError(opts ...ErrorOption) *ApiError {
4✔
1850
        eopts := parseOpts(opts)
4✔
1851
        if ae, ok := eopts.err.(*ApiError); ok {
4✔
1852
                return ae
×
1853
        }
×
1854

1855
        return ApiErrors[JSConsumerWithFlowControlNeedsHeartbeats]
4✔
1856
}
1857

1858
// NewJSInsufficientResourcesError creates a new JSInsufficientResourcesErr error: "insufficient resources"
1859
func NewJSInsufficientResourcesError(opts ...ErrorOption) *ApiError {
13✔
1860
        eopts := parseOpts(opts)
13✔
1861
        if ae, ok := eopts.err.(*ApiError); ok {
13✔
1862
                return ae
×
1863
        }
×
1864

1865
        return ApiErrors[JSInsufficientResourcesErr]
13✔
1866
}
1867

1868
// NewJSInvalidJSONError creates a new JSInvalidJSONErr error: "invalid JSON: {err}"
1869
func NewJSInvalidJSONError(err error, opts ...ErrorOption) *ApiError {
8✔
1870
        eopts := parseOpts(opts)
8✔
1871
        if ae, ok := eopts.err.(*ApiError); ok {
8✔
1872
                return ae
×
1873
        }
×
1874

1875
        e := ApiErrors[JSInvalidJSONErr]
8✔
1876
        args := e.toReplacerArgs([]interface{}{"{err}", err})
8✔
1877
        return &ApiError{
8✔
1878
                Code:        e.Code,
8✔
1879
                ErrCode:     e.ErrCode,
8✔
1880
                Description: strings.NewReplacer(args...).Replace(e.Description),
8✔
1881
        }
8✔
1882
}
1883

1884
// NewJSMaximumConsumersLimitError creates a new JSMaximumConsumersLimitErr error: "maximum consumers limit reached"
1885
func NewJSMaximumConsumersLimitError(opts ...ErrorOption) *ApiError {
43✔
1886
        eopts := parseOpts(opts)
43✔
1887
        if ae, ok := eopts.err.(*ApiError); ok {
43✔
1888
                return ae
×
1889
        }
×
1890

1891
        return ApiErrors[JSMaximumConsumersLimitErr]
43✔
1892
}
1893

1894
// NewJSMaximumStreamsLimitError creates a new JSMaximumStreamsLimitErr error: "maximum number of streams reached"
1895
func NewJSMaximumStreamsLimitError(opts ...ErrorOption) *ApiError {
16✔
1896
        eopts := parseOpts(opts)
16✔
1897
        if ae, ok := eopts.err.(*ApiError); ok {
16✔
1898
                return ae
×
1899
        }
×
1900

1901
        return ApiErrors[JSMaximumStreamsLimitErr]
16✔
1902
}
1903

1904
// NewJSMemoryResourcesExceededError creates a new JSMemoryResourcesExceededErr error: "insufficient memory resources available"
1905
func NewJSMemoryResourcesExceededError(opts ...ErrorOption) *ApiError {
4✔
1906
        eopts := parseOpts(opts)
4✔
1907
        if ae, ok := eopts.err.(*ApiError); ok {
4✔
1908
                return ae
×
1909
        }
×
1910

1911
        return ApiErrors[JSMemoryResourcesExceededErr]
4✔
1912
}
1913

1914
// NewJSMessageCounterBrokenError creates a new JSMessageCounterBrokenErr error: "message counter is broken"
1915
func NewJSMessageCounterBrokenError(opts ...ErrorOption) *ApiError {
4✔
1916
        eopts := parseOpts(opts)
4✔
1917
        if ae, ok := eopts.err.(*ApiError); ok {
4✔
1918
                return ae
×
1919
        }
×
1920

1921
        return ApiErrors[JSMessageCounterBrokenErr]
4✔
1922
}
1923

1924
// NewJSMessageIncrDisabledError creates a new JSMessageIncrDisabledErr error: "message counters is disabled"
1925
func NewJSMessageIncrDisabledError(opts ...ErrorOption) *ApiError {
4✔
1926
        eopts := parseOpts(opts)
4✔
1927
        if ae, ok := eopts.err.(*ApiError); ok {
4✔
1928
                return ae
×
1929
        }
×
1930

1931
        return ApiErrors[JSMessageIncrDisabledErr]
4✔
1932
}
1933

1934
// NewJSMessageIncrInvalidError creates a new JSMessageIncrInvalidErr error: "message counter increment is invalid"
1935
func NewJSMessageIncrInvalidError(opts ...ErrorOption) *ApiError {
24✔
1936
        eopts := parseOpts(opts)
24✔
1937
        if ae, ok := eopts.err.(*ApiError); ok {
24✔
1938
                return ae
×
1939
        }
×
1940

1941
        return ApiErrors[JSMessageIncrInvalidErr]
24✔
1942
}
1943

1944
// NewJSMessageIncrMissingError creates a new JSMessageIncrMissingErr error: "message counter increment is missing"
1945
func NewJSMessageIncrMissingError(opts ...ErrorOption) *ApiError {
8✔
1946
        eopts := parseOpts(opts)
8✔
1947
        if ae, ok := eopts.err.(*ApiError); ok {
8✔
1948
                return ae
×
1949
        }
×
1950

1951
        return ApiErrors[JSMessageIncrMissingErr]
8✔
1952
}
1953

1954
// NewJSMessageIncrPayloadError creates a new JSMessageIncrPayloadErr error: "message counter has payload"
1955
func NewJSMessageIncrPayloadError(opts ...ErrorOption) *ApiError {
4✔
1956
        eopts := parseOpts(opts)
4✔
1957
        if ae, ok := eopts.err.(*ApiError); ok {
4✔
1958
                return ae
×
1959
        }
×
1960

1961
        return ApiErrors[JSMessageIncrPayloadErr]
4✔
1962
}
1963

1964
// NewJSMessageSchedulesDisabledError creates a new JSMessageSchedulesDisabledErr error: "message schedules is disabled"
1965
func NewJSMessageSchedulesDisabledError(opts ...ErrorOption) *ApiError {
20✔
1966
        eopts := parseOpts(opts)
20✔
1967
        if ae, ok := eopts.err.(*ApiError); ok {
20✔
1968
                return ae
×
1969
        }
×
1970

1971
        return ApiErrors[JSMessageSchedulesDisabledErr]
20✔
1972
}
1973

1974
// NewJSMessageSchedulesPatternInvalidError creates a new JSMessageSchedulesPatternInvalidErr error: "message schedules pattern is invalid"
1975
func NewJSMessageSchedulesPatternInvalidError(opts ...ErrorOption) *ApiError {
15✔
1976
        eopts := parseOpts(opts)
15✔
1977
        if ae, ok := eopts.err.(*ApiError); ok {
15✔
1978
                return ae
×
1979
        }
×
1980

1981
        return ApiErrors[JSMessageSchedulesPatternInvalidErr]
15✔
1982
}
1983

1984
// NewJSMessageSchedulesRollupInvalidError creates a new JSMessageSchedulesRollupInvalidErr error: "message schedules invalid rollup"
1985
func NewJSMessageSchedulesRollupInvalidError(opts ...ErrorOption) *ApiError {
8✔
1986
        eopts := parseOpts(opts)
8✔
1987
        if ae, ok := eopts.err.(*ApiError); ok {
8✔
1988
                return ae
×
1989
        }
×
1990

1991
        return ApiErrors[JSMessageSchedulesRollupInvalidErr]
8✔
1992
}
1993

1994
// NewJSMessageSchedulesSourceInvalidError creates a new JSMessageSchedulesSourceInvalidErr error: "message schedules source is invalid"
1995
func NewJSMessageSchedulesSourceInvalidError(opts ...ErrorOption) *ApiError {
32✔
1996
        eopts := parseOpts(opts)
32✔
1997
        if ae, ok := eopts.err.(*ApiError); ok {
32✔
1998
                return ae
×
1999
        }
×
2000

2001
        return ApiErrors[JSMessageSchedulesSourceInvalidErr]
32✔
2002
}
2003

2004
// NewJSMessageSchedulesTTLInvalidError creates a new JSMessageSchedulesTTLInvalidErr error: "message schedules invalid per-message TTL"
2005
func NewJSMessageSchedulesTTLInvalidError(opts ...ErrorOption) *ApiError {
10✔
2006
        eopts := parseOpts(opts)
10✔
2007
        if ae, ok := eopts.err.(*ApiError); ok {
10✔
2008
                return ae
×
2009
        }
×
2010

2011
        return ApiErrors[JSMessageSchedulesTTLInvalidErr]
10✔
2012
}
2013

2014
// NewJSMessageSchedulesTargetInvalidError creates a new JSMessageSchedulesTargetInvalidErr error: "message schedules target is invalid"
2015
func NewJSMessageSchedulesTargetInvalidError(opts ...ErrorOption) *ApiError {
30✔
2016
        eopts := parseOpts(opts)
30✔
2017
        if ae, ok := eopts.err.(*ApiError); ok {
30✔
2018
                return ae
×
2019
        }
×
2020

2021
        return ApiErrors[JSMessageSchedulesTargetInvalidErr]
30✔
2022
}
2023

2024
// NewJSMessageTTLDisabledError creates a new JSMessageTTLDisabledErr error: "per-message TTL is disabled"
2025
func NewJSMessageTTLDisabledError(opts ...ErrorOption) *ApiError {
16✔
2026
        eopts := parseOpts(opts)
16✔
2027
        if ae, ok := eopts.err.(*ApiError); ok {
16✔
2028
                return ae
×
2029
        }
×
2030

2031
        return ApiErrors[JSMessageTTLDisabledErr]
16✔
2032
}
2033

2034
// NewJSMessageTTLInvalidError creates a new JSMessageTTLInvalidErr error: "invalid per-message TTL"
2035
func NewJSMessageTTLInvalidError(opts ...ErrorOption) *ApiError {
23✔
2036
        eopts := parseOpts(opts)
23✔
2037
        if ae, ok := eopts.err.(*ApiError); ok {
23✔
2038
                return ae
×
2039
        }
×
2040

2041
        return ApiErrors[JSMessageTTLInvalidErr]
23✔
2042
}
2043

2044
// NewJSMirrorConsumerSetupFailedError creates a new JSMirrorConsumerSetupFailedErrF error: "{err}"
2045
func NewJSMirrorConsumerSetupFailedError(err error, opts ...ErrorOption) *ApiError {
×
2046
        eopts := parseOpts(opts)
×
2047
        if ae, ok := eopts.err.(*ApiError); ok {
×
2048
                return ae
×
2049
        }
×
2050

2051
        e := ApiErrors[JSMirrorConsumerSetupFailedErrF]
×
2052
        args := e.toReplacerArgs([]interface{}{"{err}", err})
×
2053
        return &ApiError{
×
2054
                Code:        e.Code,
×
2055
                ErrCode:     e.ErrCode,
×
2056
                Description: strings.NewReplacer(args...).Replace(e.Description),
×
2057
        }
×
2058
}
2059

2060
// NewJSMirrorInvalidStreamNameError creates a new JSMirrorInvalidStreamName error: "mirrored stream name is invalid"
2061
func NewJSMirrorInvalidStreamNameError(opts ...ErrorOption) *ApiError {
×
2062
        eopts := parseOpts(opts)
×
2063
        if ae, ok := eopts.err.(*ApiError); ok {
×
2064
                return ae
×
2065
        }
×
2066

2067
        return ApiErrors[JSMirrorInvalidStreamName]
×
2068
}
2069

2070
// NewJSMirrorInvalidSubjectFilterError creates a new JSMirrorInvalidSubjectFilter error: "mirror transform source: {err}"
2071
func NewJSMirrorInvalidSubjectFilterError(err error, opts ...ErrorOption) *ApiError {
2✔
2072
        eopts := parseOpts(opts)
2✔
2073
        if ae, ok := eopts.err.(*ApiError); ok {
2✔
2074
                return ae
×
2075
        }
×
2076

2077
        e := ApiErrors[JSMirrorInvalidSubjectFilter]
2✔
2078
        args := e.toReplacerArgs([]interface{}{"{err}", err})
2✔
2079
        return &ApiError{
2✔
2080
                Code:        e.Code,
2✔
2081
                ErrCode:     e.ErrCode,
2✔
2082
                Description: strings.NewReplacer(args...).Replace(e.Description),
2✔
2083
        }
2✔
2084
}
2085

2086
// NewJSMirrorInvalidTransformDestinationError creates a new JSMirrorInvalidTransformDestination error: "mirror transform: {err}"
2087
func NewJSMirrorInvalidTransformDestinationError(err error, opts ...ErrorOption) *ApiError {
2✔
2088
        eopts := parseOpts(opts)
2✔
2089
        if ae, ok := eopts.err.(*ApiError); ok {
2✔
2090
                return ae
×
2091
        }
×
2092

2093
        e := ApiErrors[JSMirrorInvalidTransformDestination]
2✔
2094
        args := e.toReplacerArgs([]interface{}{"{err}", err})
2✔
2095
        return &ApiError{
2✔
2096
                Code:        e.Code,
2✔
2097
                ErrCode:     e.ErrCode,
2✔
2098
                Description: strings.NewReplacer(args...).Replace(e.Description),
2✔
2099
        }
2✔
2100
}
2101

2102
// NewJSMirrorMaxMessageSizeTooBigError creates a new JSMirrorMaxMessageSizeTooBigErr error: "stream mirror must have max message size >= source"
2103
func NewJSMirrorMaxMessageSizeTooBigError(opts ...ErrorOption) *ApiError {
×
2104
        eopts := parseOpts(opts)
×
2105
        if ae, ok := eopts.err.(*ApiError); ok {
×
2106
                return ae
×
2107
        }
×
2108

2109
        return ApiErrors[JSMirrorMaxMessageSizeTooBigErr]
×
2110
}
2111

2112
// NewJSMirrorMultipleFiltersNotAllowedError creates a new JSMirrorMultipleFiltersNotAllowed error: "mirror with multiple subject transforms cannot also have a single subject filter"
2113
func NewJSMirrorMultipleFiltersNotAllowedError(opts ...ErrorOption) *ApiError {
1✔
2114
        eopts := parseOpts(opts)
1✔
2115
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
2116
                return ae
×
2117
        }
×
2118

2119
        return ApiErrors[JSMirrorMultipleFiltersNotAllowed]
1✔
2120
}
2121

2122
// NewJSMirrorOverlappingSubjectFiltersError creates a new JSMirrorOverlappingSubjectFilters error: "mirror subject filters can not overlap"
2123
func NewJSMirrorOverlappingSubjectFiltersError(opts ...ErrorOption) *ApiError {
2✔
2124
        eopts := parseOpts(opts)
2✔
2125
        if ae, ok := eopts.err.(*ApiError); ok {
2✔
2126
                return ae
×
2127
        }
×
2128

2129
        return ApiErrors[JSMirrorOverlappingSubjectFilters]
2✔
2130
}
2131

2132
// NewJSMirrorWithAtomicPublishError creates a new JSMirrorWithAtomicPublishErr error: "stream mirrors can not also use atomic publishing"
2133
func NewJSMirrorWithAtomicPublishError(opts ...ErrorOption) *ApiError {
4✔
2134
        eopts := parseOpts(opts)
4✔
2135
        if ae, ok := eopts.err.(*ApiError); ok {
4✔
2136
                return ae
×
2137
        }
×
2138

2139
        return ApiErrors[JSMirrorWithAtomicPublishErr]
4✔
2140
}
2141

2142
// NewJSMirrorWithCountersError creates a new JSMirrorWithCountersErr error: "stream mirrors can not also calculate counters"
2143
func NewJSMirrorWithCountersError(opts ...ErrorOption) *ApiError {
4✔
2144
        eopts := parseOpts(opts)
4✔
2145
        if ae, ok := eopts.err.(*ApiError); ok {
4✔
2146
                return ae
×
2147
        }
×
2148

2149
        return ApiErrors[JSMirrorWithCountersErr]
4✔
2150
}
2151

2152
// NewJSMirrorWithFirstSeqError creates a new JSMirrorWithFirstSeqErr error: "stream mirrors can not have first sequence configured"
2153
func NewJSMirrorWithFirstSeqError(opts ...ErrorOption) *ApiError {
2✔
2154
        eopts := parseOpts(opts)
2✔
2155
        if ae, ok := eopts.err.(*ApiError); ok {
2✔
2156
                return ae
×
2157
        }
×
2158

2159
        return ApiErrors[JSMirrorWithFirstSeqErr]
2✔
2160
}
2161

2162
// NewJSMirrorWithMsgSchedulesError creates a new JSMirrorWithMsgSchedulesErr error: "stream mirrors can not also schedule messages"
2163
func NewJSMirrorWithMsgSchedulesError(opts ...ErrorOption) *ApiError {
2✔
2164
        eopts := parseOpts(opts)
2✔
2165
        if ae, ok := eopts.err.(*ApiError); ok {
2✔
2166
                return ae
×
2167
        }
×
2168

2169
        return ApiErrors[JSMirrorWithMsgSchedulesErr]
2✔
2170
}
2171

2172
// NewJSMirrorWithSourcesError creates a new JSMirrorWithSourcesErr error: "stream mirrors can not also contain other sources"
2173
func NewJSMirrorWithSourcesError(opts ...ErrorOption) *ApiError {
×
2174
        eopts := parseOpts(opts)
×
2175
        if ae, ok := eopts.err.(*ApiError); ok {
×
2176
                return ae
×
2177
        }
×
2178

2179
        return ApiErrors[JSMirrorWithSourcesErr]
×
2180
}
2181

2182
// NewJSMirrorWithStartSeqAndTimeError creates a new JSMirrorWithStartSeqAndTimeErr error: "stream mirrors can not have both start seq and start time configured"
2183
func NewJSMirrorWithStartSeqAndTimeError(opts ...ErrorOption) *ApiError {
×
2184
        eopts := parseOpts(opts)
×
2185
        if ae, ok := eopts.err.(*ApiError); ok {
×
2186
                return ae
×
2187
        }
×
2188

2189
        return ApiErrors[JSMirrorWithStartSeqAndTimeErr]
×
2190
}
2191

2192
// NewJSMirrorWithSubjectFiltersError creates a new JSMirrorWithSubjectFiltersErr error: "stream mirrors can not contain filtered subjects"
2193
func NewJSMirrorWithSubjectFiltersError(opts ...ErrorOption) *ApiError {
×
2194
        eopts := parseOpts(opts)
×
2195
        if ae, ok := eopts.err.(*ApiError); ok {
×
2196
                return ae
×
2197
        }
×
2198

2199
        return ApiErrors[JSMirrorWithSubjectFiltersErr]
×
2200
}
2201

2202
// NewJSMirrorWithSubjectsError creates a new JSMirrorWithSubjectsErr error: "stream mirrors can not contain subjects"
2203
func NewJSMirrorWithSubjectsError(opts ...ErrorOption) *ApiError {
2✔
2204
        eopts := parseOpts(opts)
2✔
2205
        if ae, ok := eopts.err.(*ApiError); ok {
2✔
2206
                return ae
×
2207
        }
×
2208

2209
        return ApiErrors[JSMirrorWithSubjectsErr]
2✔
2210
}
2211

2212
// NewJSNoAccountError creates a new JSNoAccountErr error: "account not found"
2213
func NewJSNoAccountError(opts ...ErrorOption) *ApiError {
1✔
2214
        eopts := parseOpts(opts)
1✔
2215
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
2216
                return ae
×
2217
        }
×
2218

2219
        return ApiErrors[JSNoAccountErr]
1✔
2220
}
2221

2222
// NewJSNoLimitsError creates a new JSNoLimitsErr error: "no JetStream default or applicable tiered limit present"
2223
func NewJSNoLimitsError(opts ...ErrorOption) *ApiError {
4✔
2224
        eopts := parseOpts(opts)
4✔
2225
        if ae, ok := eopts.err.(*ApiError); ok {
4✔
2226
                return ae
×
2227
        }
×
2228

2229
        return ApiErrors[JSNoLimitsErr]
4✔
2230
}
2231

2232
// NewJSNoMessageFoundError creates a new JSNoMessageFoundErr error: "no message found"
2233
func NewJSNoMessageFoundError(opts ...ErrorOption) *ApiError {
846✔
2234
        eopts := parseOpts(opts)
846✔
2235
        if ae, ok := eopts.err.(*ApiError); ok {
846✔
2236
                return ae
×
2237
        }
×
2238

2239
        return ApiErrors[JSNoMessageFoundErr]
846✔
2240
}
2241

2242
// NewJSNotEmptyRequestError creates a new JSNotEmptyRequestErr error: "expected an empty request payload"
2243
func NewJSNotEmptyRequestError(opts ...ErrorOption) *ApiError {
3✔
2244
        eopts := parseOpts(opts)
3✔
2245
        if ae, ok := eopts.err.(*ApiError); ok {
3✔
2246
                return ae
×
2247
        }
×
2248

2249
        return ApiErrors[JSNotEmptyRequestErr]
3✔
2250
}
2251

2252
// NewJSNotEnabledError creates a new JSNotEnabledErr error: "JetStream not enabled"
2253
func NewJSNotEnabledError(opts ...ErrorOption) *ApiError {
11✔
2254
        eopts := parseOpts(opts)
11✔
2255
        if ae, ok := eopts.err.(*ApiError); ok {
11✔
2256
                return ae
×
2257
        }
×
2258

2259
        return ApiErrors[JSNotEnabledErr]
11✔
2260
}
2261

2262
// NewJSNotEnabledForAccountError creates a new JSNotEnabledForAccountErr error: "JetStream not enabled for account"
2263
func NewJSNotEnabledForAccountError(opts ...ErrorOption) *ApiError {
314✔
2264
        eopts := parseOpts(opts)
314✔
2265
        if ae, ok := eopts.err.(*ApiError); ok {
314✔
2266
                return ae
×
2267
        }
×
2268

2269
        return ApiErrors[JSNotEnabledForAccountErr]
314✔
2270
}
2271

2272
// NewJSPedanticError creates a new JSPedanticErrF error: "pedantic mode: {err}"
2273
func NewJSPedanticError(err error, opts ...ErrorOption) *ApiError {
36✔
2274
        eopts := parseOpts(opts)
36✔
2275
        if ae, ok := eopts.err.(*ApiError); ok {
36✔
2276
                return ae
×
2277
        }
×
2278

2279
        e := ApiErrors[JSPedanticErrF]
36✔
2280
        args := e.toReplacerArgs([]interface{}{"{err}", err})
36✔
2281
        return &ApiError{
36✔
2282
                Code:        e.Code,
36✔
2283
                ErrCode:     e.ErrCode,
36✔
2284
                Description: strings.NewReplacer(args...).Replace(e.Description),
36✔
2285
        }
36✔
2286
}
2287

2288
// NewJSPeerRemapError creates a new JSPeerRemapErr error: "peer remap failed"
2289
func NewJSPeerRemapError(opts ...ErrorOption) *ApiError {
5✔
2290
        eopts := parseOpts(opts)
5✔
2291
        if ae, ok := eopts.err.(*ApiError); ok {
6✔
2292
                return ae
1✔
2293
        }
1✔
2294

2295
        return ApiErrors[JSPeerRemapErr]
4✔
2296
}
2297

2298
// NewJSRaftGeneralError creates a new JSRaftGeneralErrF error: "{err}"
2299
func NewJSRaftGeneralError(err error, opts ...ErrorOption) *ApiError {
×
2300
        eopts := parseOpts(opts)
×
2301
        if ae, ok := eopts.err.(*ApiError); ok {
×
2302
                return ae
×
2303
        }
×
2304

2305
        e := ApiErrors[JSRaftGeneralErrF]
×
2306
        args := e.toReplacerArgs([]interface{}{"{err}", err})
×
2307
        return &ApiError{
×
2308
                Code:        e.Code,
×
2309
                ErrCode:     e.ErrCode,
×
2310
                Description: strings.NewReplacer(args...).Replace(e.Description),
×
2311
        }
×
2312
}
2313

2314
// NewJSReplicasCountCannotBeNegativeError creates a new JSReplicasCountCannotBeNegative error: "replicas count cannot be negative"
2315
func NewJSReplicasCountCannotBeNegativeError(opts ...ErrorOption) *ApiError {
16✔
2316
        eopts := parseOpts(opts)
16✔
2317
        if ae, ok := eopts.err.(*ApiError); ok {
16✔
2318
                return ae
×
2319
        }
×
2320

2321
        return ApiErrors[JSReplicasCountCannotBeNegative]
16✔
2322
}
2323

2324
// NewJSRequiredApiLevelError creates a new JSRequiredApiLevelErr error: "JetStream minimum api level required"
2325
func NewJSRequiredApiLevelError(opts ...ErrorOption) *ApiError {
44✔
2326
        eopts := parseOpts(opts)
44✔
2327
        if ae, ok := eopts.err.(*ApiError); ok {
44✔
2328
                return ae
×
2329
        }
×
2330

2331
        return ApiErrors[JSRequiredApiLevelErr]
44✔
2332
}
2333

2334
// NewJSRestoreSubscribeFailedError creates a new JSRestoreSubscribeFailedErrF error: "JetStream unable to subscribe to restore snapshot {subject}: {err}"
2335
func NewJSRestoreSubscribeFailedError(err error, subject interface{}, opts ...ErrorOption) *ApiError {
1✔
2336
        eopts := parseOpts(opts)
1✔
2337
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
2338
                return ae
×
2339
        }
×
2340

2341
        e := ApiErrors[JSRestoreSubscribeFailedErrF]
1✔
2342
        args := e.toReplacerArgs([]interface{}{"{err}", err, "{subject}", subject})
1✔
2343
        return &ApiError{
1✔
2344
                Code:        e.Code,
1✔
2345
                ErrCode:     e.ErrCode,
1✔
2346
                Description: strings.NewReplacer(args...).Replace(e.Description),
1✔
2347
        }
1✔
2348
}
2349

2350
// NewJSSequenceNotFoundError creates a new JSSequenceNotFoundErrF error: "sequence {seq} not found"
2351
func NewJSSequenceNotFoundError(seq uint64, opts ...ErrorOption) *ApiError {
988✔
2352
        eopts := parseOpts(opts)
988✔
2353
        if ae, ok := eopts.err.(*ApiError); ok {
988✔
2354
                return ae
×
2355
        }
×
2356

2357
        e := ApiErrors[JSSequenceNotFoundErrF]
988✔
2358
        args := e.toReplacerArgs([]interface{}{"{seq}", seq})
988✔
2359
        return &ApiError{
988✔
2360
                Code:        e.Code,
988✔
2361
                ErrCode:     e.ErrCode,
988✔
2362
                Description: strings.NewReplacer(args...).Replace(e.Description),
988✔
2363
        }
988✔
2364
}
2365

2366
// NewJSSnapshotDeliverSubjectInvalidError creates a new JSSnapshotDeliverSubjectInvalidErr error: "deliver subject not valid"
2367
func NewJSSnapshotDeliverSubjectInvalidError(opts ...ErrorOption) *ApiError {
1✔
2368
        eopts := parseOpts(opts)
1✔
2369
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
2370
                return ae
×
2371
        }
×
2372

2373
        return ApiErrors[JSSnapshotDeliverSubjectInvalidErr]
1✔
2374
}
2375

2376
// NewJSSourceConsumerSetupFailedError creates a new JSSourceConsumerSetupFailedErrF error: "{err}"
2377
func NewJSSourceConsumerSetupFailedError(err error, opts ...ErrorOption) *ApiError {
×
2378
        eopts := parseOpts(opts)
×
2379
        if ae, ok := eopts.err.(*ApiError); ok {
×
2380
                return ae
×
2381
        }
×
2382

2383
        e := ApiErrors[JSSourceConsumerSetupFailedErrF]
×
2384
        args := e.toReplacerArgs([]interface{}{"{err}", err})
×
2385
        return &ApiError{
×
2386
                Code:        e.Code,
×
2387
                ErrCode:     e.ErrCode,
×
2388
                Description: strings.NewReplacer(args...).Replace(e.Description),
×
2389
        }
×
2390
}
2391

2392
// NewJSSourceDuplicateDetectedError creates a new JSSourceDuplicateDetected error: "duplicate source configuration detected"
2393
func NewJSSourceDuplicateDetectedError(opts ...ErrorOption) *ApiError {
×
2394
        eopts := parseOpts(opts)
×
2395
        if ae, ok := eopts.err.(*ApiError); ok {
×
2396
                return ae
×
2397
        }
×
2398

2399
        return ApiErrors[JSSourceDuplicateDetected]
×
2400
}
2401

2402
// NewJSSourceInvalidStreamNameError creates a new JSSourceInvalidStreamName error: "sourced stream name is invalid"
2403
func NewJSSourceInvalidStreamNameError(opts ...ErrorOption) *ApiError {
2✔
2404
        eopts := parseOpts(opts)
2✔
2405
        if ae, ok := eopts.err.(*ApiError); ok {
2✔
2406
                return ae
×
2407
        }
×
2408

2409
        return ApiErrors[JSSourceInvalidStreamName]
2✔
2410
}
2411

2412
// NewJSSourceInvalidSubjectFilterError creates a new JSSourceInvalidSubjectFilter error: "source transform source: {err}"
2413
func NewJSSourceInvalidSubjectFilterError(err error, opts ...ErrorOption) *ApiError {
1✔
2414
        eopts := parseOpts(opts)
1✔
2415
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
2416
                return ae
×
2417
        }
×
2418

2419
        e := ApiErrors[JSSourceInvalidSubjectFilter]
1✔
2420
        args := e.toReplacerArgs([]interface{}{"{err}", err})
1✔
2421
        return &ApiError{
1✔
2422
                Code:        e.Code,
1✔
2423
                ErrCode:     e.ErrCode,
1✔
2424
                Description: strings.NewReplacer(args...).Replace(e.Description),
1✔
2425
        }
1✔
2426
}
2427

2428
// NewJSSourceInvalidTransformDestinationError creates a new JSSourceInvalidTransformDestination error: "source transform: {err}"
2429
func NewJSSourceInvalidTransformDestinationError(err error, opts ...ErrorOption) *ApiError {
1✔
2430
        eopts := parseOpts(opts)
1✔
2431
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
2432
                return ae
×
2433
        }
×
2434

2435
        e := ApiErrors[JSSourceInvalidTransformDestination]
1✔
2436
        args := e.toReplacerArgs([]interface{}{"{err}", err})
1✔
2437
        return &ApiError{
1✔
2438
                Code:        e.Code,
1✔
2439
                ErrCode:     e.ErrCode,
1✔
2440
                Description: strings.NewReplacer(args...).Replace(e.Description),
1✔
2441
        }
1✔
2442
}
2443

2444
// NewJSSourceMaxMessageSizeTooBigError creates a new JSSourceMaxMessageSizeTooBigErr error: "stream source must have max message size >= target"
2445
func NewJSSourceMaxMessageSizeTooBigError(opts ...ErrorOption) *ApiError {
×
2446
        eopts := parseOpts(opts)
×
2447
        if ae, ok := eopts.err.(*ApiError); ok {
×
2448
                return ae
×
2449
        }
×
2450

2451
        return ApiErrors[JSSourceMaxMessageSizeTooBigErr]
×
2452
}
2453

2454
// NewJSSourceMultipleFiltersNotAllowedError creates a new JSSourceMultipleFiltersNotAllowed error: "source with multiple subject transforms cannot also have a single subject filter"
2455
func NewJSSourceMultipleFiltersNotAllowedError(opts ...ErrorOption) *ApiError {
×
2456
        eopts := parseOpts(opts)
×
2457
        if ae, ok := eopts.err.(*ApiError); ok {
×
2458
                return ae
×
2459
        }
×
2460

2461
        return ApiErrors[JSSourceMultipleFiltersNotAllowed]
×
2462
}
2463

2464
// NewJSSourceOverlappingSubjectFiltersError creates a new JSSourceOverlappingSubjectFilters error: "source filters can not overlap"
2465
func NewJSSourceOverlappingSubjectFiltersError(opts ...ErrorOption) *ApiError {
×
2466
        eopts := parseOpts(opts)
×
2467
        if ae, ok := eopts.err.(*ApiError); ok {
×
2468
                return ae
×
2469
        }
×
2470

2471
        return ApiErrors[JSSourceOverlappingSubjectFilters]
×
2472
}
2473

2474
// NewJSSourceWithMsgSchedulesError creates a new JSSourceWithMsgSchedulesErr error: "stream source can not also schedule messages"
2475
func NewJSSourceWithMsgSchedulesError(opts ...ErrorOption) *ApiError {
2✔
2476
        eopts := parseOpts(opts)
2✔
2477
        if ae, ok := eopts.err.(*ApiError); ok {
2✔
2478
                return ae
×
2479
        }
×
2480

2481
        return ApiErrors[JSSourceWithMsgSchedulesErr]
2✔
2482
}
2483

2484
// NewJSStorageResourcesExceededError creates a new JSStorageResourcesExceededErr error: "insufficient storage resources available"
2485
func NewJSStorageResourcesExceededError(opts ...ErrorOption) *ApiError {
23✔
2486
        eopts := parseOpts(opts)
23✔
2487
        if ae, ok := eopts.err.(*ApiError); ok {
23✔
2488
                return ae
×
2489
        }
×
2490

2491
        return ApiErrors[JSStorageResourcesExceededErr]
23✔
2492
}
2493

2494
// NewJSStreamAssignmentError creates a new JSStreamAssignmentErrF error: "{err}"
2495
func NewJSStreamAssignmentError(err error, opts ...ErrorOption) *ApiError {
×
2496
        eopts := parseOpts(opts)
×
2497
        if ae, ok := eopts.err.(*ApiError); ok {
×
2498
                return ae
×
2499
        }
×
2500

2501
        e := ApiErrors[JSStreamAssignmentErrF]
×
2502
        args := e.toReplacerArgs([]interface{}{"{err}", err})
×
2503
        return &ApiError{
×
2504
                Code:        e.Code,
×
2505
                ErrCode:     e.ErrCode,
×
2506
                Description: strings.NewReplacer(args...).Replace(e.Description),
×
2507
        }
×
2508
}
2509

2510
// NewJSStreamCreateError creates a new JSStreamCreateErrF error: "{err}"
2511
func NewJSStreamCreateError(err error, opts ...ErrorOption) *ApiError {
55✔
2512
        eopts := parseOpts(opts)
55✔
2513
        if ae, ok := eopts.err.(*ApiError); ok {
110✔
2514
                return ae
55✔
2515
        }
55✔
2516

2517
        e := ApiErrors[JSStreamCreateErrF]
×
2518
        args := e.toReplacerArgs([]interface{}{"{err}", err})
×
2519
        return &ApiError{
×
2520
                Code:        e.Code,
×
2521
                ErrCode:     e.ErrCode,
×
2522
                Description: strings.NewReplacer(args...).Replace(e.Description),
×
2523
        }
×
2524
}
2525

2526
// NewJSStreamDeleteError creates a new JSStreamDeleteErrF error: "{err}"
2527
func NewJSStreamDeleteError(err error, opts ...ErrorOption) *ApiError {
×
2528
        eopts := parseOpts(opts)
×
2529
        if ae, ok := eopts.err.(*ApiError); ok {
×
2530
                return ae
×
2531
        }
×
2532

2533
        e := ApiErrors[JSStreamDeleteErrF]
×
2534
        args := e.toReplacerArgs([]interface{}{"{err}", err})
×
2535
        return &ApiError{
×
2536
                Code:        e.Code,
×
2537
                ErrCode:     e.ErrCode,
×
2538
                Description: strings.NewReplacer(args...).Replace(e.Description),
×
2539
        }
×
2540
}
2541

2542
// NewJSStreamDuplicateMessageConflictError creates a new JSStreamDuplicateMessageConflict error: "duplicate message id is in process"
2543
func NewJSStreamDuplicateMessageConflictError(opts ...ErrorOption) *ApiError {
67✔
2544
        eopts := parseOpts(opts)
67✔
2545
        if ae, ok := eopts.err.(*ApiError); ok {
67✔
2546
                return ae
×
2547
        }
×
2548

2549
        return ApiErrors[JSStreamDuplicateMessageConflict]
67✔
2550
}
2551

2552
// NewJSStreamExpectedLastSeqPerSubjectInvalidError creates a new JSStreamExpectedLastSeqPerSubjectInvalid error: "missing sequence for expected last sequence per subject"
2553
func NewJSStreamExpectedLastSeqPerSubjectInvalidError(opts ...ErrorOption) *ApiError {
8✔
2554
        eopts := parseOpts(opts)
8✔
2555
        if ae, ok := eopts.err.(*ApiError); ok {
8✔
2556
                return ae
×
2557
        }
×
2558

2559
        return ApiErrors[JSStreamExpectedLastSeqPerSubjectInvalid]
8✔
2560
}
2561

2562
// NewJSStreamExpectedLastSeqPerSubjectNotReadyError creates a new JSStreamExpectedLastSeqPerSubjectNotReady error: "expected last sequence per subject temporarily unavailable"
2563
func NewJSStreamExpectedLastSeqPerSubjectNotReadyError(opts ...ErrorOption) *ApiError {
×
2564
        eopts := parseOpts(opts)
×
2565
        if ae, ok := eopts.err.(*ApiError); ok {
×
2566
                return ae
×
2567
        }
×
2568

2569
        return ApiErrors[JSStreamExpectedLastSeqPerSubjectNotReady]
×
2570
}
2571

2572
// NewJSStreamExternalApiOverlapError creates a new JSStreamExternalApiOverlapErrF error: "stream external api prefix {prefix} must not overlap with {subject}"
2573
func NewJSStreamExternalApiOverlapError(prefix interface{}, subject interface{}, opts ...ErrorOption) *ApiError {
2✔
2574
        eopts := parseOpts(opts)
2✔
2575
        if ae, ok := eopts.err.(*ApiError); ok {
2✔
2576
                return ae
×
2577
        }
×
2578

2579
        e := ApiErrors[JSStreamExternalApiOverlapErrF]
2✔
2580
        args := e.toReplacerArgs([]interface{}{"{prefix}", prefix, "{subject}", subject})
2✔
2581
        return &ApiError{
2✔
2582
                Code:        e.Code,
2✔
2583
                ErrCode:     e.ErrCode,
2✔
2584
                Description: strings.NewReplacer(args...).Replace(e.Description),
2✔
2585
        }
2✔
2586
}
2587

2588
// NewJSStreamExternalDelPrefixOverlapsError creates a new JSStreamExternalDelPrefixOverlapsErrF error: "stream external delivery prefix {prefix} overlaps with stream subject {subject}"
2589
func NewJSStreamExternalDelPrefixOverlapsError(prefix interface{}, subject interface{}, opts ...ErrorOption) *ApiError {
×
2590
        eopts := parseOpts(opts)
×
2591
        if ae, ok := eopts.err.(*ApiError); ok {
×
2592
                return ae
×
2593
        }
×
2594

2595
        e := ApiErrors[JSStreamExternalDelPrefixOverlapsErrF]
×
2596
        args := e.toReplacerArgs([]interface{}{"{prefix}", prefix, "{subject}", subject})
×
2597
        return &ApiError{
×
2598
                Code:        e.Code,
×
2599
                ErrCode:     e.ErrCode,
×
2600
                Description: strings.NewReplacer(args...).Replace(e.Description),
×
2601
        }
×
2602
}
2603

2604
// NewJSStreamGeneralError creates a new JSStreamGeneralErrorF error: "{err}"
2605
func NewJSStreamGeneralError(err error, opts ...ErrorOption) *ApiError {
3✔
2606
        eopts := parseOpts(opts)
3✔
2607
        if ae, ok := eopts.err.(*ApiError); ok {
3✔
2608
                return ae
×
2609
        }
×
2610

2611
        e := ApiErrors[JSStreamGeneralErrorF]
3✔
2612
        args := e.toReplacerArgs([]interface{}{"{err}", err})
3✔
2613
        return &ApiError{
3✔
2614
                Code:        e.Code,
3✔
2615
                ErrCode:     e.ErrCode,
3✔
2616
                Description: strings.NewReplacer(args...).Replace(e.Description),
3✔
2617
        }
3✔
2618
}
2619

2620
// NewJSStreamHeaderExceedsMaximumError creates a new JSStreamHeaderExceedsMaximumErr error: "header size exceeds maximum allowed of 64k"
2621
func NewJSStreamHeaderExceedsMaximumError(opts ...ErrorOption) *ApiError {
1✔
2622
        eopts := parseOpts(opts)
1✔
2623
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
2624
                return ae
×
2625
        }
×
2626

2627
        return ApiErrors[JSStreamHeaderExceedsMaximumErr]
1✔
2628
}
2629

2630
// NewJSStreamInfoMaxSubjectsError creates a new JSStreamInfoMaxSubjectsErr error: "subject details would exceed maximum allowed"
2631
func NewJSStreamInfoMaxSubjectsError(opts ...ErrorOption) *ApiError {
×
2632
        eopts := parseOpts(opts)
×
2633
        if ae, ok := eopts.err.(*ApiError); ok {
×
2634
                return ae
×
2635
        }
×
2636

2637
        return ApiErrors[JSStreamInfoMaxSubjectsErr]
×
2638
}
2639

2640
// NewJSStreamInvalidConfigError creates a new JSStreamInvalidConfigF error: "{err}"
2641
func NewJSStreamInvalidConfigError(err error, opts ...ErrorOption) *ApiError {
163✔
2642
        eopts := parseOpts(opts)
163✔
2643
        if ae, ok := eopts.err.(*ApiError); ok {
182✔
2644
                return ae
19✔
2645
        }
19✔
2646

2647
        e := ApiErrors[JSStreamInvalidConfigF]
144✔
2648
        args := e.toReplacerArgs([]interface{}{"{err}", err})
144✔
2649
        return &ApiError{
144✔
2650
                Code:        e.Code,
144✔
2651
                ErrCode:     e.ErrCode,
144✔
2652
                Description: strings.NewReplacer(args...).Replace(e.Description),
144✔
2653
        }
144✔
2654
}
2655

2656
// NewJSStreamInvalidError creates a new JSStreamInvalidErr error: "stream not valid"
2657
func NewJSStreamInvalidError(opts ...ErrorOption) *ApiError {
×
2658
        eopts := parseOpts(opts)
×
2659
        if ae, ok := eopts.err.(*ApiError); ok {
×
2660
                return ae
×
2661
        }
×
2662

2663
        return ApiErrors[JSStreamInvalidErr]
×
2664
}
2665

2666
// NewJSStreamInvalidExternalDeliverySubjError creates a new JSStreamInvalidExternalDeliverySubjErrF error: "stream external delivery prefix {prefix} must not contain wildcards"
2667
func NewJSStreamInvalidExternalDeliverySubjError(prefix interface{}, opts ...ErrorOption) *ApiError {
×
2668
        eopts := parseOpts(opts)
×
2669
        if ae, ok := eopts.err.(*ApiError); ok {
×
2670
                return ae
×
2671
        }
×
2672

2673
        e := ApiErrors[JSStreamInvalidExternalDeliverySubjErrF]
×
2674
        args := e.toReplacerArgs([]interface{}{"{prefix}", prefix})
×
2675
        return &ApiError{
×
2676
                Code:        e.Code,
×
2677
                ErrCode:     e.ErrCode,
×
2678
                Description: strings.NewReplacer(args...).Replace(e.Description),
×
2679
        }
×
2680
}
2681

2682
// NewJSStreamLimitsError creates a new JSStreamLimitsErrF error: "{err}"
2683
func NewJSStreamLimitsError(err error, opts ...ErrorOption) *ApiError {
9✔
2684
        eopts := parseOpts(opts)
9✔
2685
        if ae, ok := eopts.err.(*ApiError); ok {
18✔
2686
                return ae
9✔
2687
        }
9✔
2688

2689
        e := ApiErrors[JSStreamLimitsErrF]
×
2690
        args := e.toReplacerArgs([]interface{}{"{err}", err})
×
2691
        return &ApiError{
×
2692
                Code:        e.Code,
×
2693
                ErrCode:     e.ErrCode,
×
2694
                Description: strings.NewReplacer(args...).Replace(e.Description),
×
2695
        }
×
2696
}
2697

2698
// NewJSStreamMaxBytesRequiredError creates a new JSStreamMaxBytesRequired error: "account requires a stream config to have max bytes set"
2699
func NewJSStreamMaxBytesRequiredError(opts ...ErrorOption) *ApiError {
3✔
2700
        eopts := parseOpts(opts)
3✔
2701
        if ae, ok := eopts.err.(*ApiError); ok {
3✔
2702
                return ae
×
2703
        }
×
2704

2705
        return ApiErrors[JSStreamMaxBytesRequired]
3✔
2706
}
2707

2708
// NewJSStreamMaxStreamBytesExceededError creates a new JSStreamMaxStreamBytesExceeded error: "stream max bytes exceeds account limit max stream bytes"
2709
func NewJSStreamMaxStreamBytesExceededError(opts ...ErrorOption) *ApiError {
2✔
2710
        eopts := parseOpts(opts)
2✔
2711
        if ae, ok := eopts.err.(*ApiError); ok {
2✔
2712
                return ae
×
2713
        }
×
2714

2715
        return ApiErrors[JSStreamMaxStreamBytesExceeded]
2✔
2716
}
2717

2718
// NewJSStreamMessageExceedsMaximumError creates a new JSStreamMessageExceedsMaximumErr error: "message size exceeds maximum allowed"
2719
func NewJSStreamMessageExceedsMaximumError(opts ...ErrorOption) *ApiError {
19✔
2720
        eopts := parseOpts(opts)
19✔
2721
        if ae, ok := eopts.err.(*ApiError); ok {
19✔
2722
                return ae
×
2723
        }
×
2724

2725
        return ApiErrors[JSStreamMessageExceedsMaximumErr]
19✔
2726
}
2727

2728
// NewJSStreamMinLastSeqError creates a new JSStreamMinLastSeqErr error: "min last sequence"
2729
func NewJSStreamMinLastSeqError(opts ...ErrorOption) *ApiError {
×
2730
        eopts := parseOpts(opts)
×
2731
        if ae, ok := eopts.err.(*ApiError); ok {
×
2732
                return ae
×
2733
        }
×
2734

2735
        return ApiErrors[JSStreamMinLastSeqErr]
×
2736
}
2737

2738
// NewJSStreamMirrorNotUpdatableError creates a new JSStreamMirrorNotUpdatableErr error: "stream mirror configuration can not be updated"
2739
func NewJSStreamMirrorNotUpdatableError(opts ...ErrorOption) *ApiError {
2✔
2740
        eopts := parseOpts(opts)
2✔
2741
        if ae, ok := eopts.err.(*ApiError); ok {
2✔
2742
                return ae
×
2743
        }
×
2744

2745
        return ApiErrors[JSStreamMirrorNotUpdatableErr]
2✔
2746
}
2747

2748
// NewJSStreamMismatchError creates a new JSStreamMismatchErr error: "stream name in subject does not match request"
2749
func NewJSStreamMismatchError(opts ...ErrorOption) *ApiError {
3✔
2750
        eopts := parseOpts(opts)
3✔
2751
        if ae, ok := eopts.err.(*ApiError); ok {
3✔
2752
                return ae
×
2753
        }
×
2754

2755
        return ApiErrors[JSStreamMismatchErr]
3✔
2756
}
2757

2758
// NewJSStreamMoveAndScaleError creates a new JSStreamMoveAndScaleErr error: "can not move and scale a stream in a single update"
2759
func NewJSStreamMoveAndScaleError(opts ...ErrorOption) *ApiError {
4✔
2760
        eopts := parseOpts(opts)
4✔
2761
        if ae, ok := eopts.err.(*ApiError); ok {
4✔
2762
                return ae
×
2763
        }
×
2764

2765
        return ApiErrors[JSStreamMoveAndScaleErr]
4✔
2766
}
2767

2768
// NewJSStreamMoveInProgressError creates a new JSStreamMoveInProgressF error: "stream move already in progress: {msg}"
2769
func NewJSStreamMoveInProgressError(msg interface{}, opts ...ErrorOption) *ApiError {
2✔
2770
        eopts := parseOpts(opts)
2✔
2771
        if ae, ok := eopts.err.(*ApiError); ok {
2✔
2772
                return ae
×
2773
        }
×
2774

2775
        e := ApiErrors[JSStreamMoveInProgressF]
2✔
2776
        args := e.toReplacerArgs([]interface{}{"{msg}", msg})
2✔
2777
        return &ApiError{
2✔
2778
                Code:        e.Code,
2✔
2779
                ErrCode:     e.ErrCode,
2✔
2780
                Description: strings.NewReplacer(args...).Replace(e.Description),
2✔
2781
        }
2✔
2782
}
2783

2784
// NewJSStreamMoveNotInProgressError creates a new JSStreamMoveNotInProgress error: "stream move not in progress"
2785
func NewJSStreamMoveNotInProgressError(opts ...ErrorOption) *ApiError {
×
2786
        eopts := parseOpts(opts)
×
2787
        if ae, ok := eopts.err.(*ApiError); ok {
×
2788
                return ae
×
2789
        }
×
2790

2791
        return ApiErrors[JSStreamMoveNotInProgress]
×
2792
}
2793

2794
// NewJSStreamMsgDeleteFailedError creates a new JSStreamMsgDeleteFailedF error: "{err}"
2795
func NewJSStreamMsgDeleteFailedError(err error, opts ...ErrorOption) *ApiError {
11,267✔
2796
        eopts := parseOpts(opts)
11,267✔
2797
        if ae, ok := eopts.err.(*ApiError); ok {
11,267✔
2798
                return ae
×
2799
        }
×
2800

2801
        e := ApiErrors[JSStreamMsgDeleteFailedF]
11,267✔
2802
        args := e.toReplacerArgs([]interface{}{"{err}", err})
11,267✔
2803
        return &ApiError{
11,267✔
2804
                Code:        e.Code,
11,267✔
2805
                ErrCode:     e.ErrCode,
11,267✔
2806
                Description: strings.NewReplacer(args...).Replace(e.Description),
11,267✔
2807
        }
11,267✔
2808
}
2809

2810
// NewJSStreamNameContainsPathSeparatorsError creates a new JSStreamNameContainsPathSeparatorsErr error: "Stream name can not contain path separators"
2811
func NewJSStreamNameContainsPathSeparatorsError(opts ...ErrorOption) *ApiError {
6✔
2812
        eopts := parseOpts(opts)
6✔
2813
        if ae, ok := eopts.err.(*ApiError); ok {
6✔
2814
                return ae
×
2815
        }
×
2816

2817
        return ApiErrors[JSStreamNameContainsPathSeparatorsErr]
6✔
2818
}
2819

2820
// NewJSStreamNameExistError creates a new JSStreamNameExistErr error: "stream name already in use with a different configuration"
2821
func NewJSStreamNameExistError(opts ...ErrorOption) *ApiError {
10✔
2822
        eopts := parseOpts(opts)
10✔
2823
        if ae, ok := eopts.err.(*ApiError); ok {
10✔
2824
                return ae
×
2825
        }
×
2826

2827
        return ApiErrors[JSStreamNameExistErr]
10✔
2828
}
2829

2830
// NewJSStreamNameExistRestoreFailedError creates a new JSStreamNameExistRestoreFailedErr error: "stream name already in use, cannot restore"
2831
func NewJSStreamNameExistRestoreFailedError(opts ...ErrorOption) *ApiError {
3✔
2832
        eopts := parseOpts(opts)
3✔
2833
        if ae, ok := eopts.err.(*ApiError); ok {
3✔
2834
                return ae
×
2835
        }
×
2836

2837
        return ApiErrors[JSStreamNameExistRestoreFailedErr]
3✔
2838
}
2839

2840
// NewJSStreamNotFoundError creates a new JSStreamNotFoundErr error: "stream not found"
2841
func NewJSStreamNotFoundError(opts ...ErrorOption) *ApiError {
30,184✔
2842
        eopts := parseOpts(opts)
30,184✔
2843
        if ae, ok := eopts.err.(*ApiError); ok {
30,940✔
2844
                return ae
756✔
2845
        }
756✔
2846

2847
        return ApiErrors[JSStreamNotFoundErr]
29,428✔
2848
}
2849

2850
// NewJSStreamNotMatchError creates a new JSStreamNotMatchErr error: "expected stream does not match"
2851
func NewJSStreamNotMatchError(opts ...ErrorOption) *ApiError {
5✔
2852
        eopts := parseOpts(opts)
5✔
2853
        if ae, ok := eopts.err.(*ApiError); ok {
5✔
2854
                return ae
×
2855
        }
×
2856

2857
        return ApiErrors[JSStreamNotMatchErr]
5✔
2858
}
2859

2860
// NewJSStreamOfflineError creates a new JSStreamOfflineErr error: "stream is offline"
2861
func NewJSStreamOfflineError(opts ...ErrorOption) *ApiError {
6✔
2862
        eopts := parseOpts(opts)
6✔
2863
        if ae, ok := eopts.err.(*ApiError); ok {
6✔
2864
                return ae
×
2865
        }
×
2866

2867
        return ApiErrors[JSStreamOfflineErr]
6✔
2868
}
2869

2870
// NewJSStreamOfflineReasonError creates a new JSStreamOfflineReasonErrF error: "stream is offline: {err}"
2871
func NewJSStreamOfflineReasonError(err error, opts ...ErrorOption) *ApiError {
40✔
2872
        eopts := parseOpts(opts)
40✔
2873
        if ae, ok := eopts.err.(*ApiError); ok {
40✔
2874
                return ae
×
2875
        }
×
2876

2877
        e := ApiErrors[JSStreamOfflineReasonErrF]
40✔
2878
        args := e.toReplacerArgs([]interface{}{"{err}", err})
40✔
2879
        return &ApiError{
40✔
2880
                Code:        e.Code,
40✔
2881
                ErrCode:     e.ErrCode,
40✔
2882
                Description: strings.NewReplacer(args...).Replace(e.Description),
40✔
2883
        }
40✔
2884
}
2885

2886
// NewJSStreamPurgeFailedError creates a new JSStreamPurgeFailedF error: "{err}"
2887
func NewJSStreamPurgeFailedError(err error, opts ...ErrorOption) *ApiError {
1✔
2888
        eopts := parseOpts(opts)
1✔
2889
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
2890
                return ae
×
2891
        }
×
2892

2893
        e := ApiErrors[JSStreamPurgeFailedF]
1✔
2894
        args := e.toReplacerArgs([]interface{}{"{err}", err})
1✔
2895
        return &ApiError{
1✔
2896
                Code:        e.Code,
1✔
2897
                ErrCode:     e.ErrCode,
1✔
2898
                Description: strings.NewReplacer(args...).Replace(e.Description),
1✔
2899
        }
1✔
2900
}
2901

2902
// NewJSStreamReplicasNotSupportedError creates a new JSStreamReplicasNotSupportedErr error: "replicas > 1 not supported in non-clustered mode"
2903
func NewJSStreamReplicasNotSupportedError(opts ...ErrorOption) *ApiError {
1✔
2904
        eopts := parseOpts(opts)
1✔
2905
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
2906
                return ae
×
2907
        }
×
2908

2909
        return ApiErrors[JSStreamReplicasNotSupportedErr]
1✔
2910
}
2911

2912
// NewJSStreamReplicasNotUpdatableError creates a new JSStreamReplicasNotUpdatableErr error: "Replicas configuration can not be updated"
2913
func NewJSStreamReplicasNotUpdatableError(opts ...ErrorOption) *ApiError {
×
2914
        eopts := parseOpts(opts)
×
2915
        if ae, ok := eopts.err.(*ApiError); ok {
×
2916
                return ae
×
2917
        }
×
2918

2919
        return ApiErrors[JSStreamReplicasNotUpdatableErr]
×
2920
}
2921

2922
// NewJSStreamRestoreError creates a new JSStreamRestoreErrF error: "restore failed: {err}"
2923
func NewJSStreamRestoreError(err error, opts ...ErrorOption) *ApiError {
7✔
2924
        eopts := parseOpts(opts)
7✔
2925
        if ae, ok := eopts.err.(*ApiError); ok {
9✔
2926
                return ae
2✔
2927
        }
2✔
2928

2929
        e := ApiErrors[JSStreamRestoreErrF]
5✔
2930
        args := e.toReplacerArgs([]interface{}{"{err}", err})
5✔
2931
        return &ApiError{
5✔
2932
                Code:        e.Code,
5✔
2933
                ErrCode:     e.ErrCode,
5✔
2934
                Description: strings.NewReplacer(args...).Replace(e.Description),
5✔
2935
        }
5✔
2936
}
2937

2938
// NewJSStreamRollupFailedError creates a new JSStreamRollupFailedF error: "{err}"
2939
func NewJSStreamRollupFailedError(err error, opts ...ErrorOption) *ApiError {
13✔
2940
        eopts := parseOpts(opts)
13✔
2941
        if ae, ok := eopts.err.(*ApiError); ok {
13✔
2942
                return ae
×
2943
        }
×
2944

2945
        e := ApiErrors[JSStreamRollupFailedF]
13✔
2946
        args := e.toReplacerArgs([]interface{}{"{err}", err})
13✔
2947
        return &ApiError{
13✔
2948
                Code:        e.Code,
13✔
2949
                ErrCode:     e.ErrCode,
13✔
2950
                Description: strings.NewReplacer(args...).Replace(e.Description),
13✔
2951
        }
13✔
2952
}
2953

2954
// NewJSStreamSealedError creates a new JSStreamSealedErr error: "invalid operation on sealed stream"
2955
func NewJSStreamSealedError(opts ...ErrorOption) *ApiError {
10✔
2956
        eopts := parseOpts(opts)
10✔
2957
        if ae, ok := eopts.err.(*ApiError); ok {
10✔
2958
                return ae
×
2959
        }
×
2960

2961
        return ApiErrors[JSStreamSealedErr]
10✔
2962
}
2963

2964
// NewJSStreamSequenceNotMatchError creates a new JSStreamSequenceNotMatchErr error: "expected stream sequence does not match"
2965
func NewJSStreamSequenceNotMatchError(opts ...ErrorOption) *ApiError {
×
2966
        eopts := parseOpts(opts)
×
2967
        if ae, ok := eopts.err.(*ApiError); ok {
×
2968
                return ae
×
2969
        }
×
2970

2971
        return ApiErrors[JSStreamSequenceNotMatchErr]
×
2972
}
2973

2974
// NewJSStreamSnapshotError creates a new JSStreamSnapshotErrF error: "snapshot failed: {err}"
2975
func NewJSStreamSnapshotError(err error, opts ...ErrorOption) *ApiError {
×
2976
        eopts := parseOpts(opts)
×
2977
        if ae, ok := eopts.err.(*ApiError); ok {
×
2978
                return ae
×
2979
        }
×
2980

2981
        e := ApiErrors[JSStreamSnapshotErrF]
×
2982
        args := e.toReplacerArgs([]interface{}{"{err}", err})
×
2983
        return &ApiError{
×
2984
                Code:        e.Code,
×
2985
                ErrCode:     e.ErrCode,
×
2986
                Description: strings.NewReplacer(args...).Replace(e.Description),
×
2987
        }
×
2988
}
2989

2990
// NewJSStreamStoreFailedError creates a new JSStreamStoreFailedF error: "{err}"
2991
func NewJSStreamStoreFailedError(err error, opts ...ErrorOption) *ApiError {
3,464✔
2992
        eopts := parseOpts(opts)
3,464✔
2993
        if ae, ok := eopts.err.(*ApiError); ok {
3,464✔
2994
                return ae
×
2995
        }
×
2996

2997
        e := ApiErrors[JSStreamStoreFailedF]
3,464✔
2998
        args := e.toReplacerArgs([]interface{}{"{err}", err})
3,464✔
2999
        return &ApiError{
3,464✔
3000
                Code:        e.Code,
3,464✔
3001
                ErrCode:     e.ErrCode,
3,464✔
3002
                Description: strings.NewReplacer(args...).Replace(e.Description),
3,464✔
3003
        }
3,464✔
3004
}
3005

3006
// NewJSStreamSubjectOverlapError creates a new JSStreamSubjectOverlapErr error: "subjects overlap with an existing stream"
3007
func NewJSStreamSubjectOverlapError(opts ...ErrorOption) *ApiError {
25✔
3008
        eopts := parseOpts(opts)
25✔
3009
        if ae, ok := eopts.err.(*ApiError); ok {
25✔
3010
                return ae
×
3011
        }
×
3012

3013
        return ApiErrors[JSStreamSubjectOverlapErr]
25✔
3014
}
3015

3016
// NewJSStreamTemplateCreateError creates a new JSStreamTemplateCreateErrF error: "{err}"
3017
func NewJSStreamTemplateCreateError(err error, opts ...ErrorOption) *ApiError {
×
3018
        eopts := parseOpts(opts)
×
3019
        if ae, ok := eopts.err.(*ApiError); ok {
×
3020
                return ae
×
3021
        }
×
3022

3023
        e := ApiErrors[JSStreamTemplateCreateErrF]
×
3024
        args := e.toReplacerArgs([]interface{}{"{err}", err})
×
3025
        return &ApiError{
×
3026
                Code:        e.Code,
×
3027
                ErrCode:     e.ErrCode,
×
3028
                Description: strings.NewReplacer(args...).Replace(e.Description),
×
3029
        }
×
3030
}
3031

3032
// NewJSStreamTemplateDeleteError creates a new JSStreamTemplateDeleteErrF error: "{err}"
3033
func NewJSStreamTemplateDeleteError(err error, opts ...ErrorOption) *ApiError {
×
3034
        eopts := parseOpts(opts)
×
3035
        if ae, ok := eopts.err.(*ApiError); ok {
×
3036
                return ae
×
3037
        }
×
3038

3039
        e := ApiErrors[JSStreamTemplateDeleteErrF]
×
3040
        args := e.toReplacerArgs([]interface{}{"{err}", err})
×
3041
        return &ApiError{
×
3042
                Code:        e.Code,
×
3043
                ErrCode:     e.ErrCode,
×
3044
                Description: strings.NewReplacer(args...).Replace(e.Description),
×
3045
        }
×
3046
}
3047

3048
// NewJSStreamTemplateNotFoundError creates a new JSStreamTemplateNotFoundErr error: "template not found"
3049
func NewJSStreamTemplateNotFoundError(opts ...ErrorOption) *ApiError {
×
3050
        eopts := parseOpts(opts)
×
3051
        if ae, ok := eopts.err.(*ApiError); ok {
×
3052
                return ae
×
3053
        }
×
3054

3055
        return ApiErrors[JSStreamTemplateNotFoundErr]
×
3056
}
3057

3058
// NewJSStreamTooManyRequestsError creates a new JSStreamTooManyRequests error: "too many requests"
3059
func NewJSStreamTooManyRequestsError(opts ...ErrorOption) *ApiError {
190✔
3060
        eopts := parseOpts(opts)
190✔
3061
        if ae, ok := eopts.err.(*ApiError); ok {
190✔
3062
                return ae
×
3063
        }
×
3064

3065
        return ApiErrors[JSStreamTooManyRequests]
190✔
3066
}
3067

3068
// NewJSStreamTransformInvalidDestinationError creates a new JSStreamTransformInvalidDestination error: "stream transform: {err}"
3069
func NewJSStreamTransformInvalidDestinationError(err error, opts ...ErrorOption) *ApiError {
1✔
3070
        eopts := parseOpts(opts)
1✔
3071
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
3072
                return ae
×
3073
        }
×
3074

3075
        e := ApiErrors[JSStreamTransformInvalidDestination]
1✔
3076
        args := e.toReplacerArgs([]interface{}{"{err}", err})
1✔
3077
        return &ApiError{
1✔
3078
                Code:        e.Code,
1✔
3079
                ErrCode:     e.ErrCode,
1✔
3080
                Description: strings.NewReplacer(args...).Replace(e.Description),
1✔
3081
        }
1✔
3082
}
3083

3084
// NewJSStreamTransformInvalidSourceError creates a new JSStreamTransformInvalidSource error: "stream transform source: {err}"
3085
func NewJSStreamTransformInvalidSourceError(err error, opts ...ErrorOption) *ApiError {
1✔
3086
        eopts := parseOpts(opts)
1✔
3087
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
3088
                return ae
×
3089
        }
×
3090

3091
        e := ApiErrors[JSStreamTransformInvalidSource]
1✔
3092
        args := e.toReplacerArgs([]interface{}{"{err}", err})
1✔
3093
        return &ApiError{
1✔
3094
                Code:        e.Code,
1✔
3095
                ErrCode:     e.ErrCode,
1✔
3096
                Description: strings.NewReplacer(args...).Replace(e.Description),
1✔
3097
        }
1✔
3098
}
3099

3100
// NewJSStreamUpdateError creates a new JSStreamUpdateErrF error: "{err}"
3101
func NewJSStreamUpdateError(err error, opts ...ErrorOption) *ApiError {
30✔
3102
        eopts := parseOpts(opts)
30✔
3103
        if ae, ok := eopts.err.(*ApiError); ok {
54✔
3104
                return ae
24✔
3105
        }
24✔
3106

3107
        e := ApiErrors[JSStreamUpdateErrF]
6✔
3108
        args := e.toReplacerArgs([]interface{}{"{err}", err})
6✔
3109
        return &ApiError{
6✔
3110
                Code:        e.Code,
6✔
3111
                ErrCode:     e.ErrCode,
6✔
3112
                Description: strings.NewReplacer(args...).Replace(e.Description),
6✔
3113
        }
6✔
3114
}
3115

3116
// NewJSStreamWrongLastMsgIDError creates a new JSStreamWrongLastMsgIDErrF error: "wrong last msg ID: {id}"
3117
func NewJSStreamWrongLastMsgIDError(id interface{}, opts ...ErrorOption) *ApiError {
5✔
3118
        eopts := parseOpts(opts)
5✔
3119
        if ae, ok := eopts.err.(*ApiError); ok {
5✔
3120
                return ae
×
3121
        }
×
3122

3123
        e := ApiErrors[JSStreamWrongLastMsgIDErrF]
5✔
3124
        args := e.toReplacerArgs([]interface{}{"{id}", id})
5✔
3125
        return &ApiError{
5✔
3126
                Code:        e.Code,
5✔
3127
                ErrCode:     e.ErrCode,
5✔
3128
                Description: strings.NewReplacer(args...).Replace(e.Description),
5✔
3129
        }
5✔
3130
}
3131

3132
// NewJSStreamWrongLastSequenceConstantError creates a new JSStreamWrongLastSequenceConstantErr error: "wrong last sequence"
3133
func NewJSStreamWrongLastSequenceConstantError(opts ...ErrorOption) *ApiError {
24✔
3134
        eopts := parseOpts(opts)
24✔
3135
        if ae, ok := eopts.err.(*ApiError); ok {
24✔
3136
                return ae
×
3137
        }
×
3138

3139
        return ApiErrors[JSStreamWrongLastSequenceConstantErr]
24✔
3140
}
3141

3142
// NewJSStreamWrongLastSequenceError creates a new JSStreamWrongLastSequenceErrF error: "wrong last sequence: {seq}"
3143
func NewJSStreamWrongLastSequenceError(seq uint64, opts ...ErrorOption) *ApiError {
95✔
3144
        eopts := parseOpts(opts)
95✔
3145
        if ae, ok := eopts.err.(*ApiError); ok {
95✔
3146
                return ae
×
3147
        }
×
3148

3149
        e := ApiErrors[JSStreamWrongLastSequenceErrF]
95✔
3150
        args := e.toReplacerArgs([]interface{}{"{seq}", seq})
95✔
3151
        return &ApiError{
95✔
3152
                Code:        e.Code,
95✔
3153
                ErrCode:     e.ErrCode,
95✔
3154
                Description: strings.NewReplacer(args...).Replace(e.Description),
95✔
3155
        }
95✔
3156
}
3157

3158
// NewJSTempStorageFailedError creates a new JSTempStorageFailedErr error: "JetStream unable to open temp storage for restore"
3159
func NewJSTempStorageFailedError(opts ...ErrorOption) *ApiError {
×
3160
        eopts := parseOpts(opts)
×
3161
        if ae, ok := eopts.err.(*ApiError); ok {
×
3162
                return ae
×
3163
        }
×
3164

3165
        return ApiErrors[JSTempStorageFailedErr]
×
3166
}
3167

3168
// NewJSTemplateNameNotMatchSubjectError creates a new JSTemplateNameNotMatchSubjectErr error: "template name in subject does not match request"
3169
func NewJSTemplateNameNotMatchSubjectError(opts ...ErrorOption) *ApiError {
×
3170
        eopts := parseOpts(opts)
×
3171
        if ae, ok := eopts.err.(*ApiError); ok {
×
3172
                return ae
×
3173
        }
×
3174

3175
        return ApiErrors[JSTemplateNameNotMatchSubjectErr]
×
3176
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc