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

nats-io / nats-server / 18183589534

01 Oct 2025 03:37PM UTC coverage: 86.025% (-0.03%) from 86.059%
18183589534

push

github

web-flow
feat: add NewServerFromConfig function for embedded server config processing (#7364)

# Add NewServerFromConfig function for embedded server config processing

## Overview

Resolves #7092

This PR introduces a new `NewServerFromConfig()` function that
automatically processes configuration files for embedded NATS servers.

## Problem

When using NATS embedded in Go applications, developers (such as me)
often pass the `ConfigFile` field in the `Options` struct, but
`NewServer(opts *Options)` doesn't automatically process this
configuration file. This leads to confusion and requires additional
manual steps to load the configuration.

## Solution

### Approach Comparison

In pr #7333, a solution was proposed to directly modify `NewServer()`:

```go
func NewServer(opts *Options) (*Server, error) {
    if opts.ConfigFile != _EMPTY_ && opts.configDigest == "" {
        if err := opts.ProcessConfigFile(opts.ConfigFile); err != nil {
            return nil, err
        }
    }
    // ...original code
}
```

However, directly modifying `NewServer()` might raise concerns about
backward compatibility. Therefore, this PR introduces a dedicated
`NewServerFromConfig()` function specifically to handle the `ConfigFile`
field of `*Options`.

### Implementation

This PR adds:

```go
func NewServerFromConfig(opts *Options) (*Server, error) {
    if opts.ConfigFile != _EMPTY_ && opts.configDigest == "" {
        if err := opts.ProcessConfigFile(opts.ConfigFile); err != nil {
            return nil, err
        }
    }
    return NewServer(opts)
}
```

## Testing

Added comprehensive test coverage:

- **`TestNewServerFromConfigFunctionality`**: Tests basic functionality
and error handling scenarios
- **`TestNewServerFromConfigVsLoadConfig`**: Validates equivalence with
traditional `LoadConfig()` approach using deep equality checks

## Acknowledgments

Thanks to @ripienaar for the suggestion to create a separate function
instead of modifying `NewServer()` directly.

## Sign... (continued)

74392 of 86477 relevant lines covered (86.03%)

352743.25 hits per line

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

55.91
/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
        // JSAtomicPublishDisabledErr atomic publish is disabled
12
        JSAtomicPublishDisabledErr ErrorIdentifier = 10174
13

14
        // JSAtomicPublishIncompleteBatchErr atomic publish batch is incomplete
15
        JSAtomicPublishIncompleteBatchErr ErrorIdentifier = 10176
16

17
        // JSAtomicPublishInvalidBatchCommitErr atomic publish batch commit is invalid
18
        JSAtomicPublishInvalidBatchCommitErr ErrorIdentifier = 10200
19

20
        // JSAtomicPublishInvalidBatchIDErr atomic publish batch ID is invalid
21
        JSAtomicPublishInvalidBatchIDErr ErrorIdentifier = 10179
22

23
        // JSAtomicPublishMissingSeqErr atomic publish sequence is missing
24
        JSAtomicPublishMissingSeqErr ErrorIdentifier = 10175
25

26
        // JSAtomicPublishTooLargeBatchErrF atomic publish batch is too large: {size}
27
        JSAtomicPublishTooLargeBatchErrF ErrorIdentifier = 10199
28

29
        // JSAtomicPublishUnsupportedHeaderBatchErr atomic publish unsupported header used: {header}
30
        JSAtomicPublishUnsupportedHeaderBatchErr ErrorIdentifier = 10177
31

32
        // JSBadRequestErr bad request
33
        JSBadRequestErr ErrorIdentifier = 10003
34

35
        // JSClusterIncompleteErr incomplete results
36
        JSClusterIncompleteErr ErrorIdentifier = 10004
37

38
        // JSClusterNoPeersErrF Error causing no peers to be available ({err})
39
        JSClusterNoPeersErrF ErrorIdentifier = 10005
40

41
        // JSClusterNotActiveErr JetStream not in clustered mode
42
        JSClusterNotActiveErr ErrorIdentifier = 10006
43

44
        // JSClusterNotAssignedErr JetStream cluster not assigned to this server
45
        JSClusterNotAssignedErr ErrorIdentifier = 10007
46

47
        // JSClusterNotAvailErr JetStream system temporarily unavailable
48
        JSClusterNotAvailErr ErrorIdentifier = 10008
49

50
        // JSClusterNotLeaderErr JetStream cluster can not handle request
51
        JSClusterNotLeaderErr ErrorIdentifier = 10009
52

53
        // JSClusterPeerNotMemberErr peer not a member
54
        JSClusterPeerNotMemberErr ErrorIdentifier = 10040
55

56
        // JSClusterRequiredErr JetStream clustering support required
57
        JSClusterRequiredErr ErrorIdentifier = 10010
58

59
        // JSClusterServerNotMemberErr server is not a member of the cluster
60
        JSClusterServerNotMemberErr ErrorIdentifier = 10044
61

62
        // JSClusterTagsErr tags placement not supported for operation
63
        JSClusterTagsErr ErrorIdentifier = 10011
64

65
        // JSClusterUnSupportFeatureErr not currently supported in clustered mode
66
        JSClusterUnSupportFeatureErr ErrorIdentifier = 10036
67

68
        // JSConsumerAckPolicyInvalidErr consumer ack policy invalid
69
        JSConsumerAckPolicyInvalidErr ErrorIdentifier = 10181
70

71
        // JSConsumerAckWaitNegativeErr consumer ack wait needs to be positive
72
        JSConsumerAckWaitNegativeErr ErrorIdentifier = 10183
73

74
        // JSConsumerAlreadyExists action CREATE is used for a existing consumer with a different config (consumer already exists)
75
        JSConsumerAlreadyExists ErrorIdentifier = 10148
76

77
        // JSConsumerBackOffNegativeErr consumer backoff needs to be positive
78
        JSConsumerBackOffNegativeErr ErrorIdentifier = 10184
79

80
        // JSConsumerBadDurableNameErr durable name can not contain '.', '*', '>'
81
        JSConsumerBadDurableNameErr ErrorIdentifier = 10103
82

83
        // JSConsumerConfigRequiredErr consumer config required
84
        JSConsumerConfigRequiredErr ErrorIdentifier = 10078
85

86
        // JSConsumerCreateDurableAndNameMismatch Consumer Durable and Name have to be equal if both are provided
87
        JSConsumerCreateDurableAndNameMismatch ErrorIdentifier = 10132
88

89
        // JSConsumerCreateErrF General consumer creation failure string ({err})
90
        JSConsumerCreateErrF ErrorIdentifier = 10012
91

92
        // JSConsumerCreateFilterSubjectMismatchErr Consumer create request did not match filtered subject from create subject
93
        JSConsumerCreateFilterSubjectMismatchErr ErrorIdentifier = 10131
94

95
        // JSConsumerDeliverCycleErr consumer deliver subject forms a cycle
96
        JSConsumerDeliverCycleErr ErrorIdentifier = 10081
97

98
        // JSConsumerDeliverToWildcardsErr consumer deliver subject has wildcards
99
        JSConsumerDeliverToWildcardsErr ErrorIdentifier = 10079
100

101
        // JSConsumerDescriptionTooLongErrF consumer description is too long, maximum allowed is {max}
102
        JSConsumerDescriptionTooLongErrF ErrorIdentifier = 10107
103

104
        // JSConsumerDirectRequiresEphemeralErr consumer direct requires an ephemeral consumer
105
        JSConsumerDirectRequiresEphemeralErr ErrorIdentifier = 10091
106

107
        // JSConsumerDirectRequiresPushErr consumer direct requires a push based consumer
108
        JSConsumerDirectRequiresPushErr ErrorIdentifier = 10090
109

110
        // JSConsumerDoesNotExist action UPDATE is used for a nonexisting consumer (consumer does not exist)
111
        JSConsumerDoesNotExist ErrorIdentifier = 10149
112

113
        // JSConsumerDuplicateFilterSubjects consumer cannot have both FilterSubject and FilterSubjects specified
114
        JSConsumerDuplicateFilterSubjects ErrorIdentifier = 10136
115

116
        // JSConsumerDurableNameNotInSubjectErr consumer expected to be durable but no durable name set in subject
117
        JSConsumerDurableNameNotInSubjectErr ErrorIdentifier = 10016
118

119
        // JSConsumerDurableNameNotMatchSubjectErr consumer name in subject does not match durable name in request
120
        JSConsumerDurableNameNotMatchSubjectErr ErrorIdentifier = 10017
121

122
        // JSConsumerDurableNameNotSetErr consumer expected to be durable but a durable name was not set
123
        JSConsumerDurableNameNotSetErr ErrorIdentifier = 10018
124

125
        // JSConsumerEmptyFilter consumer filter in FilterSubjects cannot be empty
126
        JSConsumerEmptyFilter ErrorIdentifier = 10139
127

128
        // JSConsumerEmptyGroupName Group name cannot be an empty string
129
        JSConsumerEmptyGroupName ErrorIdentifier = 10161
130

131
        // JSConsumerEphemeralWithDurableInSubjectErr consumer expected to be ephemeral but detected a durable name set in subject
132
        JSConsumerEphemeralWithDurableInSubjectErr ErrorIdentifier = 10019
133

134
        // JSConsumerEphemeralWithDurableNameErr consumer expected to be ephemeral but a durable name was set in request
135
        JSConsumerEphemeralWithDurableNameErr ErrorIdentifier = 10020
136

137
        // JSConsumerExistingActiveErr consumer already exists and is still active
138
        JSConsumerExistingActiveErr ErrorIdentifier = 10105
139

140
        // JSConsumerFCRequiresPushErr consumer flow control requires a push based consumer
141
        JSConsumerFCRequiresPushErr ErrorIdentifier = 10089
142

143
        // JSConsumerFilterNotSubsetErr consumer filter subject is not a valid subset of the interest subjects
144
        JSConsumerFilterNotSubsetErr ErrorIdentifier = 10093
145

146
        // JSConsumerHBRequiresPushErr consumer idle heartbeat requires a push based consumer
147
        JSConsumerHBRequiresPushErr ErrorIdentifier = 10088
148

149
        // JSConsumerInactiveThresholdExcess consumer inactive threshold exceeds system limit of {limit}
150
        JSConsumerInactiveThresholdExcess ErrorIdentifier = 10153
151

152
        // JSConsumerInvalidDeliverSubject invalid push consumer deliver subject
153
        JSConsumerInvalidDeliverSubject ErrorIdentifier = 10112
154

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

158
        // JSConsumerInvalidPolicyErrF Generic delivery policy error ({err})
159
        JSConsumerInvalidPolicyErrF ErrorIdentifier = 10094
160

161
        // JSConsumerInvalidPriorityGroupErr Provided priority group does not exist for this consumer
162
        JSConsumerInvalidPriorityGroupErr ErrorIdentifier = 10160
163

164
        // JSConsumerInvalidSamplingErrF failed to parse consumer sampling configuration: {err}
165
        JSConsumerInvalidSamplingErrF ErrorIdentifier = 10095
166

167
        // JSConsumerMaxDeliverBackoffErr max deliver is required to be > length of backoff values
168
        JSConsumerMaxDeliverBackoffErr ErrorIdentifier = 10116
169

170
        // JSConsumerMaxPendingAckExcessErrF consumer max ack pending exceeds system limit of {limit}
171
        JSConsumerMaxPendingAckExcessErrF ErrorIdentifier = 10121
172

173
        // JSConsumerMaxPendingAckPolicyRequiredErr consumer requires ack policy for max ack pending
174
        JSConsumerMaxPendingAckPolicyRequiredErr ErrorIdentifier = 10082
175

176
        // JSConsumerMaxRequestBatchExceededF consumer max request batch exceeds server limit of {limit}
177
        JSConsumerMaxRequestBatchExceededF ErrorIdentifier = 10125
178

179
        // JSConsumerMaxRequestBatchNegativeErr consumer max request batch needs to be > 0
180
        JSConsumerMaxRequestBatchNegativeErr ErrorIdentifier = 10114
181

182
        // JSConsumerMaxRequestExpiresTooSmall consumer max request expires needs to be >= 1ms
183
        JSConsumerMaxRequestExpiresTooSmall ErrorIdentifier = 10115
184

185
        // JSConsumerMaxWaitingNegativeErr consumer max waiting needs to be positive
186
        JSConsumerMaxWaitingNegativeErr ErrorIdentifier = 10087
187

188
        // JSConsumerMetadataLengthErrF consumer metadata exceeds maximum size of {limit}
189
        JSConsumerMetadataLengthErrF ErrorIdentifier = 10135
190

191
        // JSConsumerMultipleFiltersNotAllowed consumer with multiple subject filters cannot use subject based API
192
        JSConsumerMultipleFiltersNotAllowed ErrorIdentifier = 10137
193

194
        // JSConsumerNameContainsPathSeparatorsErr Consumer name can not contain path separators
195
        JSConsumerNameContainsPathSeparatorsErr ErrorIdentifier = 10127
196

197
        // JSConsumerNameExistErr consumer name already in use
198
        JSConsumerNameExistErr ErrorIdentifier = 10013
199

200
        // JSConsumerNameTooLongErrF consumer name is too long, maximum allowed is {max}
201
        JSConsumerNameTooLongErrF ErrorIdentifier = 10102
202

203
        // JSConsumerNotFoundErr consumer not found
204
        JSConsumerNotFoundErr ErrorIdentifier = 10014
205

206
        // JSConsumerOfflineErr consumer is offline
207
        JSConsumerOfflineErr ErrorIdentifier = 10119
208

209
        // JSConsumerOfflineReasonErrF consumer is offline: {err}
210
        JSConsumerOfflineReasonErrF ErrorIdentifier = 10195
211

212
        // JSConsumerOnMappedErr consumer direct on a mapped consumer
213
        JSConsumerOnMappedErr ErrorIdentifier = 10092
214

215
        // JSConsumerOverlappingSubjectFilters consumer subject filters cannot overlap
216
        JSConsumerOverlappingSubjectFilters ErrorIdentifier = 10138
217

218
        // JSConsumerPinnedTTLWithoutPriorityPolicyNone PinnedTTL cannot be set when PriorityPolicy is none
219
        JSConsumerPinnedTTLWithoutPriorityPolicyNone ErrorIdentifier = 10197
220

221
        // JSConsumerPriorityGroupWithPolicyNone consumer can not have priority groups when policy is none
222
        JSConsumerPriorityGroupWithPolicyNone ErrorIdentifier = 10196
223

224
        // JSConsumerPriorityPolicyWithoutGroup Setting PriorityPolicy requires at least one PriorityGroup to be set
225
        JSConsumerPriorityPolicyWithoutGroup ErrorIdentifier = 10159
226

227
        // JSConsumerPullNotDurableErr consumer in pull mode requires a durable name
228
        JSConsumerPullNotDurableErr ErrorIdentifier = 10085
229

230
        // JSConsumerPullRequiresAckErr consumer in pull mode requires explicit ack policy on workqueue stream
231
        JSConsumerPullRequiresAckErr ErrorIdentifier = 10084
232

233
        // JSConsumerPullWithRateLimitErr consumer in pull mode can not have rate limit set
234
        JSConsumerPullWithRateLimitErr ErrorIdentifier = 10086
235

236
        // JSConsumerPushMaxWaitingErr consumer in push mode can not set max waiting
237
        JSConsumerPushMaxWaitingErr ErrorIdentifier = 10080
238

239
        // JSConsumerPushWithPriorityGroupErr priority groups can not be used with push consumers
240
        JSConsumerPushWithPriorityGroupErr ErrorIdentifier = 10178
241

242
        // JSConsumerReplacementWithDifferentNameErr consumer replacement durable config not the same
243
        JSConsumerReplacementWithDifferentNameErr ErrorIdentifier = 10106
244

245
        // JSConsumerReplayPolicyInvalidErr consumer replay policy invalid
246
        JSConsumerReplayPolicyInvalidErr ErrorIdentifier = 10182
247

248
        // JSConsumerReplicasExceedsStream consumer config replica count exceeds parent stream
249
        JSConsumerReplicasExceedsStream ErrorIdentifier = 10126
250

251
        // JSConsumerReplicasShouldMatchStream consumer config replicas must match interest retention stream's replicas
252
        JSConsumerReplicasShouldMatchStream ErrorIdentifier = 10134
253

254
        // JSConsumerSmallHeartbeatErr consumer idle heartbeat needs to be >= 100ms
255
        JSConsumerSmallHeartbeatErr ErrorIdentifier = 10083
256

257
        // JSConsumerStoreFailedErrF error creating store for consumer: {err}
258
        JSConsumerStoreFailedErrF ErrorIdentifier = 10104
259

260
        // JSConsumerWQConsumerNotDeliverAllErr consumer must be deliver all on workqueue stream
261
        JSConsumerWQConsumerNotDeliverAllErr ErrorIdentifier = 10101
262

263
        // JSConsumerWQConsumerNotUniqueErr filtered consumer not unique on workqueue stream
264
        JSConsumerWQConsumerNotUniqueErr ErrorIdentifier = 10100
265

266
        // JSConsumerWQMultipleUnfilteredErr multiple non-filtered consumers not allowed on workqueue stream
267
        JSConsumerWQMultipleUnfilteredErr ErrorIdentifier = 10099
268

269
        // JSConsumerWQRequiresExplicitAckErr workqueue stream requires explicit ack
270
        JSConsumerWQRequiresExplicitAckErr ErrorIdentifier = 10098
271

272
        // JSConsumerWithFlowControlNeedsHeartbeats consumer with flow control also needs heartbeats
273
        JSConsumerWithFlowControlNeedsHeartbeats ErrorIdentifier = 10108
274

275
        // JSInsufficientResourcesErr insufficient resources
276
        JSInsufficientResourcesErr ErrorIdentifier = 10023
277

278
        // JSInvalidJSONErr invalid JSON: {err}
279
        JSInvalidJSONErr ErrorIdentifier = 10025
280

281
        // JSMaximumConsumersLimitErr maximum consumers limit reached
282
        JSMaximumConsumersLimitErr ErrorIdentifier = 10026
283

284
        // JSMaximumStreamsLimitErr maximum number of streams reached
285
        JSMaximumStreamsLimitErr ErrorIdentifier = 10027
286

287
        // JSMemoryResourcesExceededErr insufficient memory resources available
288
        JSMemoryResourcesExceededErr ErrorIdentifier = 10028
289

290
        // JSMessageCounterBrokenErr message counter is broken
291
        JSMessageCounterBrokenErr ErrorIdentifier = 10172
292

293
        // JSMessageIncrDisabledErr message counters is disabled
294
        JSMessageIncrDisabledErr ErrorIdentifier = 10168
295

296
        // JSMessageIncrInvalidErr message counter increment is invalid
297
        JSMessageIncrInvalidErr ErrorIdentifier = 10171
298

299
        // JSMessageIncrMissingErr message counter increment is missing
300
        JSMessageIncrMissingErr ErrorIdentifier = 10169
301

302
        // JSMessageIncrPayloadErr message counter has payload
303
        JSMessageIncrPayloadErr ErrorIdentifier = 10170
304

305
        // JSMessageSchedulesDisabledErr message schedules is disabled
306
        JSMessageSchedulesDisabledErr ErrorIdentifier = 10188
307

308
        // JSMessageSchedulesPatternInvalidErr message schedules pattern is invalid
309
        JSMessageSchedulesPatternInvalidErr ErrorIdentifier = 10189
310

311
        // JSMessageSchedulesRollupInvalidErr message schedules invalid rollup
312
        JSMessageSchedulesRollupInvalidErr ErrorIdentifier = 10192
313

314
        // JSMessageSchedulesTTLInvalidErr message schedules invalid per-message TTL
315
        JSMessageSchedulesTTLInvalidErr ErrorIdentifier = 10191
316

317
        // JSMessageSchedulesTargetInvalidErr message schedules target is invalid
318
        JSMessageSchedulesTargetInvalidErr ErrorIdentifier = 10190
319

320
        // JSMessageTTLDisabledErr per-message TTL is disabled
321
        JSMessageTTLDisabledErr ErrorIdentifier = 10166
322

323
        // JSMessageTTLInvalidErr invalid per-message TTL
324
        JSMessageTTLInvalidErr ErrorIdentifier = 10165
325

326
        // JSMirrorConsumerSetupFailedErrF generic mirror consumer setup failure string ({err})
327
        JSMirrorConsumerSetupFailedErrF ErrorIdentifier = 10029
328

329
        // JSMirrorInvalidStreamName mirrored stream name is invalid
330
        JSMirrorInvalidStreamName ErrorIdentifier = 10142
331

332
        // JSMirrorInvalidSubjectFilter mirror transform source: {err}
333
        JSMirrorInvalidSubjectFilter ErrorIdentifier = 10151
334

335
        // JSMirrorInvalidTransformDestination mirror transform: {err}
336
        JSMirrorInvalidTransformDestination ErrorIdentifier = 10154
337

338
        // JSMirrorMaxMessageSizeTooBigErr stream mirror must have max message size >= source
339
        JSMirrorMaxMessageSizeTooBigErr ErrorIdentifier = 10030
340

341
        // JSMirrorMultipleFiltersNotAllowed mirror with multiple subject transforms cannot also have a single subject filter
342
        JSMirrorMultipleFiltersNotAllowed ErrorIdentifier = 10150
343

344
        // JSMirrorOverlappingSubjectFilters mirror subject filters can not overlap
345
        JSMirrorOverlappingSubjectFilters ErrorIdentifier = 10152
346

347
        // JSMirrorWithAtomicPublishErr stream mirrors can not also use atomic publishing
348
        JSMirrorWithAtomicPublishErr ErrorIdentifier = 10198
349

350
        // JSMirrorWithCountersErr stream mirrors can not also calculate counters
351
        JSMirrorWithCountersErr ErrorIdentifier = 10173
352

353
        // JSMirrorWithFirstSeqErr stream mirrors can not have first sequence configured
354
        JSMirrorWithFirstSeqErr ErrorIdentifier = 10143
355

356
        // JSMirrorWithMsgSchedulesErr stream mirrors can not also schedule messages
357
        JSMirrorWithMsgSchedulesErr ErrorIdentifier = 10186
358

359
        // JSMirrorWithSourcesErr stream mirrors can not also contain other sources
360
        JSMirrorWithSourcesErr ErrorIdentifier = 10031
361

362
        // JSMirrorWithStartSeqAndTimeErr stream mirrors can not have both start seq and start time configured
363
        JSMirrorWithStartSeqAndTimeErr ErrorIdentifier = 10032
364

365
        // JSMirrorWithSubjectFiltersErr stream mirrors can not contain filtered subjects
366
        JSMirrorWithSubjectFiltersErr ErrorIdentifier = 10033
367

368
        // JSMirrorWithSubjectsErr stream mirrors can not contain subjects
369
        JSMirrorWithSubjectsErr ErrorIdentifier = 10034
370

371
        // JSNoAccountErr account not found
372
        JSNoAccountErr ErrorIdentifier = 10035
373

374
        // JSNoLimitsErr no JetStream default or applicable tiered limit present
375
        JSNoLimitsErr ErrorIdentifier = 10120
376

377
        // JSNoMessageFoundErr no message found
378
        JSNoMessageFoundErr ErrorIdentifier = 10037
379

380
        // JSNotEmptyRequestErr expected an empty request payload
381
        JSNotEmptyRequestErr ErrorIdentifier = 10038
382

383
        // JSNotEnabledErr JetStream not enabled
384
        JSNotEnabledErr ErrorIdentifier = 10076
385

386
        // JSNotEnabledForAccountErr JetStream not enabled for account
387
        JSNotEnabledForAccountErr ErrorIdentifier = 10039
388

389
        // JSPedanticErrF pedantic mode: {err}
390
        JSPedanticErrF ErrorIdentifier = 10157
391

392
        // JSPeerRemapErr peer remap failed
393
        JSPeerRemapErr ErrorIdentifier = 10075
394

395
        // JSRaftGeneralErrF General RAFT error string ({err})
396
        JSRaftGeneralErrF ErrorIdentifier = 10041
397

398
        // JSReplicasCountCannotBeNegative replicas count cannot be negative
399
        JSReplicasCountCannotBeNegative ErrorIdentifier = 10133
400

401
        // JSRequiredApiLevelErr JetStream minimum api level required
402
        JSRequiredApiLevelErr ErrorIdentifier = 10185
403

404
        // JSRestoreSubscribeFailedErrF JetStream unable to subscribe to restore snapshot {subject}: {err}
405
        JSRestoreSubscribeFailedErrF ErrorIdentifier = 10042
406

407
        // JSSequenceNotFoundErrF sequence {seq} not found
408
        JSSequenceNotFoundErrF ErrorIdentifier = 10043
409

410
        // JSSnapshotDeliverSubjectInvalidErr deliver subject not valid
411
        JSSnapshotDeliverSubjectInvalidErr ErrorIdentifier = 10015
412

413
        // JSSourceConsumerSetupFailedErrF General source consumer setup failure string ({err})
414
        JSSourceConsumerSetupFailedErrF ErrorIdentifier = 10045
415

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

419
        // JSSourceInvalidStreamName sourced stream name is invalid
420
        JSSourceInvalidStreamName ErrorIdentifier = 10141
421

422
        // JSSourceInvalidSubjectFilter source transform source: {err}
423
        JSSourceInvalidSubjectFilter ErrorIdentifier = 10145
424

425
        // JSSourceInvalidTransformDestination source transform: {err}
426
        JSSourceInvalidTransformDestination ErrorIdentifier = 10146
427

428
        // JSSourceMaxMessageSizeTooBigErr stream source must have max message size >= target
429
        JSSourceMaxMessageSizeTooBigErr ErrorIdentifier = 10046
430

431
        // JSSourceMultipleFiltersNotAllowed source with multiple subject transforms cannot also have a single subject filter
432
        JSSourceMultipleFiltersNotAllowed ErrorIdentifier = 10144
433

434
        // JSSourceOverlappingSubjectFilters source filters can not overlap
435
        JSSourceOverlappingSubjectFilters ErrorIdentifier = 10147
436

437
        // JSSourceWithMsgSchedulesErr stream source can not also schedule messages
438
        JSSourceWithMsgSchedulesErr ErrorIdentifier = 10187
439

440
        // JSStorageResourcesExceededErr insufficient storage resources available
441
        JSStorageResourcesExceededErr ErrorIdentifier = 10047
442

443
        // JSStreamAssignmentErrF Generic stream assignment error string ({err})
444
        JSStreamAssignmentErrF ErrorIdentifier = 10048
445

446
        // JSStreamCreateErrF Generic stream creation error string ({err})
447
        JSStreamCreateErrF ErrorIdentifier = 10049
448

449
        // JSStreamDeleteErrF General stream deletion error string ({err})
450
        JSStreamDeleteErrF ErrorIdentifier = 10050
451

452
        // JSStreamDuplicateMessageConflict duplicate message id is in process
453
        JSStreamDuplicateMessageConflict ErrorIdentifier = 10158
454

455
        // JSStreamExpectedLastSeqPerSubjectInvalid missing sequence for expected last sequence per subject
456
        JSStreamExpectedLastSeqPerSubjectInvalid ErrorIdentifier = 10193
457

458
        // JSStreamExpectedLastSeqPerSubjectNotReady expected last sequence per subject temporarily unavailable
459
        JSStreamExpectedLastSeqPerSubjectNotReady ErrorIdentifier = 10163
460

461
        // JSStreamExternalApiOverlapErrF stream external api prefix {prefix} must not overlap with {subject}
462
        JSStreamExternalApiOverlapErrF ErrorIdentifier = 10021
463

464
        // JSStreamExternalDelPrefixOverlapsErrF stream external delivery prefix {prefix} overlaps with stream subject {subject}
465
        JSStreamExternalDelPrefixOverlapsErrF ErrorIdentifier = 10022
466

467
        // JSStreamGeneralErrorF General stream failure string ({err})
468
        JSStreamGeneralErrorF ErrorIdentifier = 10051
469

470
        // JSStreamHeaderExceedsMaximumErr header size exceeds maximum allowed of 64k
471
        JSStreamHeaderExceedsMaximumErr ErrorIdentifier = 10097
472

473
        // JSStreamInfoMaxSubjectsErr subject details would exceed maximum allowed
474
        JSStreamInfoMaxSubjectsErr ErrorIdentifier = 10117
475

476
        // JSStreamInvalidConfigF Stream configuration validation error string ({err})
477
        JSStreamInvalidConfigF ErrorIdentifier = 10052
478

479
        // JSStreamInvalidErr stream not valid
480
        JSStreamInvalidErr ErrorIdentifier = 10096
481

482
        // JSStreamInvalidExternalDeliverySubjErrF stream external delivery prefix {prefix} must not contain wildcards
483
        JSStreamInvalidExternalDeliverySubjErrF ErrorIdentifier = 10024
484

485
        // JSStreamLimitsErrF General stream limits exceeded error string ({err})
486
        JSStreamLimitsErrF ErrorIdentifier = 10053
487

488
        // JSStreamMaxBytesRequired account requires a stream config to have max bytes set
489
        JSStreamMaxBytesRequired ErrorIdentifier = 10113
490

491
        // JSStreamMaxStreamBytesExceeded stream max bytes exceeds account limit max stream bytes
492
        JSStreamMaxStreamBytesExceeded ErrorIdentifier = 10122
493

494
        // JSStreamMessageExceedsMaximumErr message size exceeds maximum allowed
495
        JSStreamMessageExceedsMaximumErr ErrorIdentifier = 10054
496

497
        // JSStreamMinLastSeqErr min last sequence
498
        JSStreamMinLastSeqErr ErrorIdentifier = 10180
499

500
        // JSStreamMirrorNotUpdatableErr stream mirror configuration can not be updated
501
        JSStreamMirrorNotUpdatableErr ErrorIdentifier = 10055
502

503
        // JSStreamMismatchErr stream name in subject does not match request
504
        JSStreamMismatchErr ErrorIdentifier = 10056
505

506
        // JSStreamMoveAndScaleErr can not move and scale a stream in a single update
507
        JSStreamMoveAndScaleErr ErrorIdentifier = 10123
508

509
        // JSStreamMoveInProgressF stream move already in progress: {msg}
510
        JSStreamMoveInProgressF ErrorIdentifier = 10124
511

512
        // JSStreamMoveNotInProgress stream move not in progress
513
        JSStreamMoveNotInProgress ErrorIdentifier = 10129
514

515
        // JSStreamMsgDeleteFailedF Generic message deletion failure error string ({err})
516
        JSStreamMsgDeleteFailedF ErrorIdentifier = 10057
517

518
        // JSStreamNameContainsPathSeparatorsErr Stream name can not contain path separators
519
        JSStreamNameContainsPathSeparatorsErr ErrorIdentifier = 10128
520

521
        // JSStreamNameExistErr stream name already in use with a different configuration
522
        JSStreamNameExistErr ErrorIdentifier = 10058
523

524
        // JSStreamNameExistRestoreFailedErr stream name already in use, cannot restore
525
        JSStreamNameExistRestoreFailedErr ErrorIdentifier = 10130
526

527
        // JSStreamNotFoundErr stream not found
528
        JSStreamNotFoundErr ErrorIdentifier = 10059
529

530
        // JSStreamNotMatchErr expected stream does not match
531
        JSStreamNotMatchErr ErrorIdentifier = 10060
532

533
        // JSStreamOfflineErr stream is offline
534
        JSStreamOfflineErr ErrorIdentifier = 10118
535

536
        // JSStreamOfflineReasonErrF stream is offline: {err}
537
        JSStreamOfflineReasonErrF ErrorIdentifier = 10194
538

539
        // JSStreamPurgeFailedF Generic stream purge failure error string ({err})
540
        JSStreamPurgeFailedF ErrorIdentifier = 10110
541

542
        // JSStreamReplicasNotSupportedErr replicas > 1 not supported in non-clustered mode
543
        JSStreamReplicasNotSupportedErr ErrorIdentifier = 10074
544

545
        // JSStreamReplicasNotUpdatableErr Replicas configuration can not be updated
546
        JSStreamReplicasNotUpdatableErr ErrorIdentifier = 10061
547

548
        // JSStreamRestoreErrF restore failed: {err}
549
        JSStreamRestoreErrF ErrorIdentifier = 10062
550

551
        // JSStreamRollupFailedF Generic stream rollup failure error string ({err})
552
        JSStreamRollupFailedF ErrorIdentifier = 10111
553

554
        // JSStreamSealedErr invalid operation on sealed stream
555
        JSStreamSealedErr ErrorIdentifier = 10109
556

557
        // JSStreamSequenceNotMatchErr expected stream sequence does not match
558
        JSStreamSequenceNotMatchErr ErrorIdentifier = 10063
559

560
        // JSStreamSnapshotErrF snapshot failed: {err}
561
        JSStreamSnapshotErrF ErrorIdentifier = 10064
562

563
        // JSStreamStoreFailedF Generic error when storing a message failed ({err})
564
        JSStreamStoreFailedF ErrorIdentifier = 10077
565

566
        // JSStreamSubjectOverlapErr subjects overlap with an existing stream
567
        JSStreamSubjectOverlapErr ErrorIdentifier = 10065
568

569
        // JSStreamTemplateCreateErrF Generic template creation failed string ({err})
570
        JSStreamTemplateCreateErrF ErrorIdentifier = 10066
571

572
        // JSStreamTemplateDeleteErrF Generic stream template deletion failed error string ({err})
573
        JSStreamTemplateDeleteErrF ErrorIdentifier = 10067
574

575
        // JSStreamTemplateNotFoundErr template not found
576
        JSStreamTemplateNotFoundErr ErrorIdentifier = 10068
577

578
        // JSStreamTooManyRequests too many requests
579
        JSStreamTooManyRequests ErrorIdentifier = 10167
580

581
        // JSStreamTransformInvalidDestination stream transform: {err}
582
        JSStreamTransformInvalidDestination ErrorIdentifier = 10156
583

584
        // JSStreamTransformInvalidSource stream transform source: {err}
585
        JSStreamTransformInvalidSource ErrorIdentifier = 10155
586

587
        // JSStreamUpdateErrF Generic stream update error string ({err})
588
        JSStreamUpdateErrF ErrorIdentifier = 10069
589

590
        // JSStreamWrongLastMsgIDErrF wrong last msg ID: {id}
591
        JSStreamWrongLastMsgIDErrF ErrorIdentifier = 10070
592

593
        // JSStreamWrongLastSequenceConstantErr wrong last sequence
594
        JSStreamWrongLastSequenceConstantErr ErrorIdentifier = 10164
595

596
        // JSStreamWrongLastSequenceErrF wrong last sequence: {seq}
597
        JSStreamWrongLastSequenceErrF ErrorIdentifier = 10071
598

599
        // JSTempStorageFailedErr JetStream unable to open temp storage for restore
600
        JSTempStorageFailedErr ErrorIdentifier = 10072
601

602
        // JSTemplateNameNotMatchSubjectErr template name in subject does not match request
603
        JSTemplateNameNotMatchSubjectErr ErrorIdentifier = 10073
604
)
605

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

832
// NewJSAccountResourcesExceededError creates a new JSAccountResourcesExceededErr error: "resource limits exceeded for account"
833
func NewJSAccountResourcesExceededError(opts ...ErrorOption) *ApiError {
20,060✔
834
        eopts := parseOpts(opts)
20,060✔
835
        if ae, ok := eopts.err.(*ApiError); ok {
20,060✔
836
                return ae
×
837
        }
×
838

839
        return ApiErrors[JSAccountResourcesExceededErr]
20,060✔
840
}
841

842
// NewJSAtomicPublishDisabledError creates a new JSAtomicPublishDisabledErr error: "atomic publish is disabled"
843
func NewJSAtomicPublishDisabledError(opts ...ErrorOption) *ApiError {
24✔
844
        eopts := parseOpts(opts)
24✔
845
        if ae, ok := eopts.err.(*ApiError); ok {
24✔
846
                return ae
×
847
        }
×
848

849
        return ApiErrors[JSAtomicPublishDisabledErr]
24✔
850
}
851

852
// NewJSAtomicPublishIncompleteBatchError creates a new JSAtomicPublishIncompleteBatchErr error: "atomic publish batch is incomplete"
853
func NewJSAtomicPublishIncompleteBatchError(opts ...ErrorOption) *ApiError {
62✔
854
        eopts := parseOpts(opts)
62✔
855
        if ae, ok := eopts.err.(*ApiError); ok {
62✔
856
                return ae
×
857
        }
×
858

859
        return ApiErrors[JSAtomicPublishIncompleteBatchErr]
62✔
860
}
861

862
// NewJSAtomicPublishInvalidBatchCommitError creates a new JSAtomicPublishInvalidBatchCommitErr error: "atomic publish batch commit is invalid"
863
func NewJSAtomicPublishInvalidBatchCommitError(opts ...ErrorOption) *ApiError {
6✔
864
        eopts := parseOpts(opts)
6✔
865
        if ae, ok := eopts.err.(*ApiError); ok {
6✔
866
                return ae
×
867
        }
×
868

869
        return ApiErrors[JSAtomicPublishInvalidBatchCommitErr]
6✔
870
}
871

872
// NewJSAtomicPublishInvalidBatchIDError creates a new JSAtomicPublishInvalidBatchIDErr error: "atomic publish batch ID is invalid"
873
func NewJSAtomicPublishInvalidBatchIDError(opts ...ErrorOption) *ApiError {
4✔
874
        eopts := parseOpts(opts)
4✔
875
        if ae, ok := eopts.err.(*ApiError); ok {
4✔
876
                return ae
×
877
        }
×
878

879
        return ApiErrors[JSAtomicPublishInvalidBatchIDErr]
4✔
880
}
881

882
// NewJSAtomicPublishMissingSeqError creates a new JSAtomicPublishMissingSeqErr error: "atomic publish sequence is missing"
883
func NewJSAtomicPublishMissingSeqError(opts ...ErrorOption) *ApiError {
24✔
884
        eopts := parseOpts(opts)
24✔
885
        if ae, ok := eopts.err.(*ApiError); ok {
24✔
886
                return ae
×
887
        }
×
888

889
        return ApiErrors[JSAtomicPublishMissingSeqErr]
24✔
890
}
891

892
// NewJSAtomicPublishTooLargeBatchError creates a new JSAtomicPublishTooLargeBatchErrF error: "atomic publish batch is too large: {size}"
893
func NewJSAtomicPublishTooLargeBatchError(size interface{}, opts ...ErrorOption) *ApiError {
10✔
894
        eopts := parseOpts(opts)
10✔
895
        if ae, ok := eopts.err.(*ApiError); ok {
10✔
896
                return ae
×
897
        }
×
898

899
        e := ApiErrors[JSAtomicPublishTooLargeBatchErrF]
10✔
900
        args := e.toReplacerArgs([]interface{}{"{size}", size})
10✔
901
        return &ApiError{
10✔
902
                Code:        e.Code,
10✔
903
                ErrCode:     e.ErrCode,
10✔
904
                Description: strings.NewReplacer(args...).Replace(e.Description),
10✔
905
        }
10✔
906
}
907

908
// NewJSAtomicPublishUnsupportedHeaderBatchError creates a new JSAtomicPublishUnsupportedHeaderBatchErr error: "atomic publish unsupported header used: {header}"
909
func NewJSAtomicPublishUnsupportedHeaderBatchError(header interface{}, opts ...ErrorOption) *ApiError {
32✔
910
        eopts := parseOpts(opts)
32✔
911
        if ae, ok := eopts.err.(*ApiError); ok {
32✔
912
                return ae
×
913
        }
×
914

915
        e := ApiErrors[JSAtomicPublishUnsupportedHeaderBatchErr]
32✔
916
        args := e.toReplacerArgs([]interface{}{"{header}", header})
32✔
917
        return &ApiError{
32✔
918
                Code:        e.Code,
32✔
919
                ErrCode:     e.ErrCode,
32✔
920
                Description: strings.NewReplacer(args...).Replace(e.Description),
32✔
921
        }
32✔
922
}
923

924
// NewJSBadRequestError creates a new JSBadRequestErr error: "bad request"
925
func NewJSBadRequestError(opts ...ErrorOption) *ApiError {
10✔
926
        eopts := parseOpts(opts)
10✔
927
        if ae, ok := eopts.err.(*ApiError); ok {
10✔
928
                return ae
×
929
        }
×
930

931
        return ApiErrors[JSBadRequestErr]
10✔
932
}
933

934
// NewJSClusterIncompleteError creates a new JSClusterIncompleteErr error: "incomplete results"
935
func NewJSClusterIncompleteError(opts ...ErrorOption) *ApiError {
×
936
        eopts := parseOpts(opts)
×
937
        if ae, ok := eopts.err.(*ApiError); ok {
×
938
                return ae
×
939
        }
×
940

941
        return ApiErrors[JSClusterIncompleteErr]
×
942
}
943

944
// NewJSClusterNoPeersError creates a new JSClusterNoPeersErrF error: "{err}"
945
func NewJSClusterNoPeersError(err error, opts ...ErrorOption) *ApiError {
58✔
946
        eopts := parseOpts(opts)
58✔
947
        if ae, ok := eopts.err.(*ApiError); ok {
58✔
948
                return ae
×
949
        }
×
950

951
        e := ApiErrors[JSClusterNoPeersErrF]
58✔
952
        args := e.toReplacerArgs([]interface{}{"{err}", err})
58✔
953
        return &ApiError{
58✔
954
                Code:        e.Code,
58✔
955
                ErrCode:     e.ErrCode,
58✔
956
                Description: strings.NewReplacer(args...).Replace(e.Description),
58✔
957
        }
58✔
958
}
959

960
// NewJSClusterNotActiveError creates a new JSClusterNotActiveErr error: "JetStream not in clustered mode"
961
func NewJSClusterNotActiveError(opts ...ErrorOption) *ApiError {
1✔
962
        eopts := parseOpts(opts)
1✔
963
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
964
                return ae
×
965
        }
×
966

967
        return ApiErrors[JSClusterNotActiveErr]
1✔
968
}
969

970
// NewJSClusterNotAssignedError creates a new JSClusterNotAssignedErr error: "JetStream cluster not assigned to this server"
971
func NewJSClusterNotAssignedError(opts ...ErrorOption) *ApiError {
32✔
972
        eopts := parseOpts(opts)
32✔
973
        if ae, ok := eopts.err.(*ApiError); ok {
32✔
974
                return ae
×
975
        }
×
976

977
        return ApiErrors[JSClusterNotAssignedErr]
32✔
978
}
979

980
// NewJSClusterNotAvailError creates a new JSClusterNotAvailErr error: "JetStream system temporarily unavailable"
981
func NewJSClusterNotAvailError(opts ...ErrorOption) *ApiError {
13✔
982
        eopts := parseOpts(opts)
13✔
983
        if ae, ok := eopts.err.(*ApiError); ok {
13✔
984
                return ae
×
985
        }
×
986

987
        return ApiErrors[JSClusterNotAvailErr]
13✔
988
}
989

990
// NewJSClusterNotLeaderError creates a new JSClusterNotLeaderErr error: "JetStream cluster can not handle request"
991
func NewJSClusterNotLeaderError(opts ...ErrorOption) *ApiError {
690✔
992
        eopts := parseOpts(opts)
690✔
993
        if ae, ok := eopts.err.(*ApiError); ok {
690✔
994
                return ae
×
995
        }
×
996

997
        return ApiErrors[JSClusterNotLeaderErr]
690✔
998
}
999

1000
// NewJSClusterPeerNotMemberError creates a new JSClusterPeerNotMemberErr error: "peer not a member"
1001
func NewJSClusterPeerNotMemberError(opts ...ErrorOption) *ApiError {
1✔
1002
        eopts := parseOpts(opts)
1✔
1003
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
1004
                return ae
×
1005
        }
×
1006

1007
        return ApiErrors[JSClusterPeerNotMemberErr]
1✔
1008
}
1009

1010
// NewJSClusterRequiredError creates a new JSClusterRequiredErr error: "JetStream clustering support required"
1011
func NewJSClusterRequiredError(opts ...ErrorOption) *ApiError {
×
1012
        eopts := parseOpts(opts)
×
1013
        if ae, ok := eopts.err.(*ApiError); ok {
×
1014
                return ae
×
1015
        }
×
1016

1017
        return ApiErrors[JSClusterRequiredErr]
×
1018
}
1019

1020
// NewJSClusterServerNotMemberError creates a new JSClusterServerNotMemberErr error: "server is not a member of the cluster"
1021
func NewJSClusterServerNotMemberError(opts ...ErrorOption) *ApiError {
3✔
1022
        eopts := parseOpts(opts)
3✔
1023
        if ae, ok := eopts.err.(*ApiError); ok {
3✔
1024
                return ae
×
1025
        }
×
1026

1027
        return ApiErrors[JSClusterServerNotMemberErr]
3✔
1028
}
1029

1030
// NewJSClusterTagsError creates a new JSClusterTagsErr error: "tags placement not supported for operation"
1031
func NewJSClusterTagsError(opts ...ErrorOption) *ApiError {
×
1032
        eopts := parseOpts(opts)
×
1033
        if ae, ok := eopts.err.(*ApiError); ok {
×
1034
                return ae
×
1035
        }
×
1036

1037
        return ApiErrors[JSClusterTagsErr]
×
1038
}
1039

1040
// NewJSClusterUnSupportFeatureError creates a new JSClusterUnSupportFeatureErr error: "not currently supported in clustered mode"
1041
func NewJSClusterUnSupportFeatureError(opts ...ErrorOption) *ApiError {
6✔
1042
        eopts := parseOpts(opts)
6✔
1043
        if ae, ok := eopts.err.(*ApiError); ok {
6✔
1044
                return ae
×
1045
        }
×
1046

1047
        return ApiErrors[JSClusterUnSupportFeatureErr]
6✔
1048
}
1049

1050
// NewJSConsumerAckPolicyInvalidError creates a new JSConsumerAckPolicyInvalidErr error: "consumer ack policy invalid"
1051
func NewJSConsumerAckPolicyInvalidError(opts ...ErrorOption) *ApiError {
2✔
1052
        eopts := parseOpts(opts)
2✔
1053
        if ae, ok := eopts.err.(*ApiError); ok {
2✔
1054
                return ae
×
1055
        }
×
1056

1057
        return ApiErrors[JSConsumerAckPolicyInvalidErr]
2✔
1058
}
1059

1060
// NewJSConsumerAckWaitNegativeError creates a new JSConsumerAckWaitNegativeErr error: "consumer ack wait needs to be positive"
1061
func NewJSConsumerAckWaitNegativeError(opts ...ErrorOption) *ApiError {
2✔
1062
        eopts := parseOpts(opts)
2✔
1063
        if ae, ok := eopts.err.(*ApiError); ok {
2✔
1064
                return ae
×
1065
        }
×
1066

1067
        return ApiErrors[JSConsumerAckWaitNegativeErr]
2✔
1068
}
1069

1070
// NewJSConsumerAlreadyExistsError creates a new JSConsumerAlreadyExists error: "consumer already exists"
1071
func NewJSConsumerAlreadyExistsError(opts ...ErrorOption) *ApiError {
5✔
1072
        eopts := parseOpts(opts)
5✔
1073
        if ae, ok := eopts.err.(*ApiError); ok {
5✔
1074
                return ae
×
1075
        }
×
1076

1077
        return ApiErrors[JSConsumerAlreadyExists]
5✔
1078
}
1079

1080
// NewJSConsumerBackOffNegativeError creates a new JSConsumerBackOffNegativeErr error: "consumer backoff needs to be positive"
1081
func NewJSConsumerBackOffNegativeError(opts ...ErrorOption) *ApiError {
2✔
1082
        eopts := parseOpts(opts)
2✔
1083
        if ae, ok := eopts.err.(*ApiError); ok {
2✔
1084
                return ae
×
1085
        }
×
1086

1087
        return ApiErrors[JSConsumerBackOffNegativeErr]
2✔
1088
}
1089

1090
// NewJSConsumerBadDurableNameError creates a new JSConsumerBadDurableNameErr error: "durable name can not contain '.', '*', '>'"
1091
func NewJSConsumerBadDurableNameError(opts ...ErrorOption) *ApiError {
×
1092
        eopts := parseOpts(opts)
×
1093
        if ae, ok := eopts.err.(*ApiError); ok {
×
1094
                return ae
×
1095
        }
×
1096

1097
        return ApiErrors[JSConsumerBadDurableNameErr]
×
1098
}
1099

1100
// NewJSConsumerConfigRequiredError creates a new JSConsumerConfigRequiredErr error: "consumer config required"
1101
func NewJSConsumerConfigRequiredError(opts ...ErrorOption) *ApiError {
2✔
1102
        eopts := parseOpts(opts)
2✔
1103
        if ae, ok := eopts.err.(*ApiError); ok {
2✔
1104
                return ae
×
1105
        }
×
1106

1107
        return ApiErrors[JSConsumerConfigRequiredErr]
2✔
1108
}
1109

1110
// NewJSConsumerCreateDurableAndNameMismatchError creates a new JSConsumerCreateDurableAndNameMismatch error: "Consumer Durable and Name have to be equal if both are provided"
1111
func NewJSConsumerCreateDurableAndNameMismatchError(opts ...ErrorOption) *ApiError {
1✔
1112
        eopts := parseOpts(opts)
1✔
1113
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
1114
                return ae
×
1115
        }
×
1116

1117
        return ApiErrors[JSConsumerCreateDurableAndNameMismatch]
1✔
1118
}
1119

1120
// NewJSConsumerCreateError creates a new JSConsumerCreateErrF error: "{err}"
1121
func NewJSConsumerCreateError(err error, opts ...ErrorOption) *ApiError {
71✔
1122
        eopts := parseOpts(opts)
71✔
1123
        if ae, ok := eopts.err.(*ApiError); ok {
124✔
1124
                return ae
53✔
1125
        }
53✔
1126

1127
        e := ApiErrors[JSConsumerCreateErrF]
18✔
1128
        args := e.toReplacerArgs([]interface{}{"{err}", err})
18✔
1129
        return &ApiError{
18✔
1130
                Code:        e.Code,
18✔
1131
                ErrCode:     e.ErrCode,
18✔
1132
                Description: strings.NewReplacer(args...).Replace(e.Description),
18✔
1133
        }
18✔
1134
}
1135

1136
// NewJSConsumerCreateFilterSubjectMismatchError creates a new JSConsumerCreateFilterSubjectMismatchErr error: "Consumer create request did not match filtered subject from create subject"
1137
func NewJSConsumerCreateFilterSubjectMismatchError(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[JSConsumerCreateFilterSubjectMismatchErr]
2✔
1144
}
1145

1146
// NewJSConsumerDeliverCycleError creates a new JSConsumerDeliverCycleErr error: "consumer deliver subject forms a cycle"
1147
func NewJSConsumerDeliverCycleError(opts ...ErrorOption) *ApiError {
4✔
1148
        eopts := parseOpts(opts)
4✔
1149
        if ae, ok := eopts.err.(*ApiError); ok {
4✔
1150
                return ae
×
1151
        }
×
1152

1153
        return ApiErrors[JSConsumerDeliverCycleErr]
4✔
1154
}
1155

1156
// NewJSConsumerDeliverToWildcardsError creates a new JSConsumerDeliverToWildcardsErr error: "consumer deliver subject has wildcards"
1157
func NewJSConsumerDeliverToWildcardsError(opts ...ErrorOption) *ApiError {
4✔
1158
        eopts := parseOpts(opts)
4✔
1159
        if ae, ok := eopts.err.(*ApiError); ok {
4✔
1160
                return ae
×
1161
        }
×
1162

1163
        return ApiErrors[JSConsumerDeliverToWildcardsErr]
4✔
1164
}
1165

1166
// NewJSConsumerDescriptionTooLongError creates a new JSConsumerDescriptionTooLongErrF error: "consumer description is too long, maximum allowed is {max}"
1167
func NewJSConsumerDescriptionTooLongError(max interface{}, opts ...ErrorOption) *ApiError {
1✔
1168
        eopts := parseOpts(opts)
1✔
1169
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
1170
                return ae
×
1171
        }
×
1172

1173
        e := ApiErrors[JSConsumerDescriptionTooLongErrF]
1✔
1174
        args := e.toReplacerArgs([]interface{}{"{max}", max})
1✔
1175
        return &ApiError{
1✔
1176
                Code:        e.Code,
1✔
1177
                ErrCode:     e.ErrCode,
1✔
1178
                Description: strings.NewReplacer(args...).Replace(e.Description),
1✔
1179
        }
1✔
1180
}
1181

1182
// NewJSConsumerDirectRequiresEphemeralError creates a new JSConsumerDirectRequiresEphemeralErr error: "consumer direct requires an ephemeral consumer"
1183
func NewJSConsumerDirectRequiresEphemeralError(opts ...ErrorOption) *ApiError {
×
1184
        eopts := parseOpts(opts)
×
1185
        if ae, ok := eopts.err.(*ApiError); ok {
×
1186
                return ae
×
1187
        }
×
1188

1189
        return ApiErrors[JSConsumerDirectRequiresEphemeralErr]
×
1190
}
1191

1192
// NewJSConsumerDirectRequiresPushError creates a new JSConsumerDirectRequiresPushErr error: "consumer direct requires a push based consumer"
1193
func NewJSConsumerDirectRequiresPushError(opts ...ErrorOption) *ApiError {
×
1194
        eopts := parseOpts(opts)
×
1195
        if ae, ok := eopts.err.(*ApiError); ok {
×
1196
                return ae
×
1197
        }
×
1198

1199
        return ApiErrors[JSConsumerDirectRequiresPushErr]
×
1200
}
1201

1202
// NewJSConsumerDoesNotExistError creates a new JSConsumerDoesNotExist error: "consumer does not exist"
1203
func NewJSConsumerDoesNotExistError(opts ...ErrorOption) *ApiError {
3✔
1204
        eopts := parseOpts(opts)
3✔
1205
        if ae, ok := eopts.err.(*ApiError); ok {
3✔
1206
                return ae
×
1207
        }
×
1208

1209
        return ApiErrors[JSConsumerDoesNotExist]
3✔
1210
}
1211

1212
// NewJSConsumerDuplicateFilterSubjectsError creates a new JSConsumerDuplicateFilterSubjects error: "consumer cannot have both FilterSubject and FilterSubjects specified"
1213
func NewJSConsumerDuplicateFilterSubjectsError(opts ...ErrorOption) *ApiError {
1✔
1214
        eopts := parseOpts(opts)
1✔
1215
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
1216
                return ae
×
1217
        }
×
1218

1219
        return ApiErrors[JSConsumerDuplicateFilterSubjects]
1✔
1220
}
1221

1222
// NewJSConsumerDurableNameNotInSubjectError creates a new JSConsumerDurableNameNotInSubjectErr error: "consumer expected to be durable but no durable name set in subject"
1223
func NewJSConsumerDurableNameNotInSubjectError(opts ...ErrorOption) *ApiError {
×
1224
        eopts := parseOpts(opts)
×
1225
        if ae, ok := eopts.err.(*ApiError); ok {
×
1226
                return ae
×
1227
        }
×
1228

1229
        return ApiErrors[JSConsumerDurableNameNotInSubjectErr]
×
1230
}
1231

1232
// NewJSConsumerDurableNameNotMatchSubjectError creates a new JSConsumerDurableNameNotMatchSubjectErr error: "consumer name in subject does not match durable name in request"
1233
func NewJSConsumerDurableNameNotMatchSubjectError(opts ...ErrorOption) *ApiError {
×
1234
        eopts := parseOpts(opts)
×
1235
        if ae, ok := eopts.err.(*ApiError); ok {
×
1236
                return ae
×
1237
        }
×
1238

1239
        return ApiErrors[JSConsumerDurableNameNotMatchSubjectErr]
×
1240
}
1241

1242
// NewJSConsumerDurableNameNotSetError creates a new JSConsumerDurableNameNotSetErr error: "consumer expected to be durable but a durable name was not set"
1243
func NewJSConsumerDurableNameNotSetError(opts ...ErrorOption) *ApiError {
1✔
1244
        eopts := parseOpts(opts)
1✔
1245
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
1246
                return ae
×
1247
        }
×
1248

1249
        return ApiErrors[JSConsumerDurableNameNotSetErr]
1✔
1250
}
1251

1252
// NewJSConsumerEmptyFilterError creates a new JSConsumerEmptyFilter error: "consumer filter in FilterSubjects cannot be empty"
1253
func NewJSConsumerEmptyFilterError(opts ...ErrorOption) *ApiError {
1✔
1254
        eopts := parseOpts(opts)
1✔
1255
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
1256
                return ae
×
1257
        }
×
1258

1259
        return ApiErrors[JSConsumerEmptyFilter]
1✔
1260
}
1261

1262
// NewJSConsumerEmptyGroupNameError creates a new JSConsumerEmptyGroupName error: "Group name cannot be an empty string"
1263
func NewJSConsumerEmptyGroupNameError(opts ...ErrorOption) *ApiError {
4✔
1264
        eopts := parseOpts(opts)
4✔
1265
        if ae, ok := eopts.err.(*ApiError); ok {
4✔
1266
                return ae
×
1267
        }
×
1268

1269
        return ApiErrors[JSConsumerEmptyGroupName]
4✔
1270
}
1271

1272
// NewJSConsumerEphemeralWithDurableInSubjectError creates a new JSConsumerEphemeralWithDurableInSubjectErr error: "consumer expected to be ephemeral but detected a durable name set in subject"
1273
func NewJSConsumerEphemeralWithDurableInSubjectError(opts ...ErrorOption) *ApiError {
×
1274
        eopts := parseOpts(opts)
×
1275
        if ae, ok := eopts.err.(*ApiError); ok {
×
1276
                return ae
×
1277
        }
×
1278

1279
        return ApiErrors[JSConsumerEphemeralWithDurableInSubjectErr]
×
1280
}
1281

1282
// NewJSConsumerEphemeralWithDurableNameError creates a new JSConsumerEphemeralWithDurableNameErr error: "consumer expected to be ephemeral but a durable name was set in request"
1283
func NewJSConsumerEphemeralWithDurableNameError(opts ...ErrorOption) *ApiError {
3✔
1284
        eopts := parseOpts(opts)
3✔
1285
        if ae, ok := eopts.err.(*ApiError); ok {
3✔
1286
                return ae
×
1287
        }
×
1288

1289
        return ApiErrors[JSConsumerEphemeralWithDurableNameErr]
3✔
1290
}
1291

1292
// NewJSConsumerExistingActiveError creates a new JSConsumerExistingActiveErr error: "consumer already exists and is still active"
1293
func NewJSConsumerExistingActiveError(opts ...ErrorOption) *ApiError {
×
1294
        eopts := parseOpts(opts)
×
1295
        if ae, ok := eopts.err.(*ApiError); ok {
×
1296
                return ae
×
1297
        }
×
1298

1299
        return ApiErrors[JSConsumerExistingActiveErr]
×
1300
}
1301

1302
// NewJSConsumerFCRequiresPushError creates a new JSConsumerFCRequiresPushErr error: "consumer flow control requires a push based consumer"
1303
func NewJSConsumerFCRequiresPushError(opts ...ErrorOption) *ApiError {
×
1304
        eopts := parseOpts(opts)
×
1305
        if ae, ok := eopts.err.(*ApiError); ok {
×
1306
                return ae
×
1307
        }
×
1308

1309
        return ApiErrors[JSConsumerFCRequiresPushErr]
×
1310
}
1311

1312
// NewJSConsumerFilterNotSubsetError creates a new JSConsumerFilterNotSubsetErr error: "consumer filter subject is not a valid subset of the interest subjects"
1313
func NewJSConsumerFilterNotSubsetError(opts ...ErrorOption) *ApiError {
×
1314
        eopts := parseOpts(opts)
×
1315
        if ae, ok := eopts.err.(*ApiError); ok {
×
1316
                return ae
×
1317
        }
×
1318

1319
        return ApiErrors[JSConsumerFilterNotSubsetErr]
×
1320
}
1321

1322
// NewJSConsumerHBRequiresPushError creates a new JSConsumerHBRequiresPushErr error: "consumer idle heartbeat requires a push based consumer"
1323
func NewJSConsumerHBRequiresPushError(opts ...ErrorOption) *ApiError {
×
1324
        eopts := parseOpts(opts)
×
1325
        if ae, ok := eopts.err.(*ApiError); ok {
×
1326
                return ae
×
1327
        }
×
1328

1329
        return ApiErrors[JSConsumerHBRequiresPushErr]
×
1330
}
1331

1332
// NewJSConsumerInactiveThresholdExcessError creates a new JSConsumerInactiveThresholdExcess error: "consumer inactive threshold exceeds system limit of {limit}"
1333
func NewJSConsumerInactiveThresholdExcessError(limit interface{}, opts ...ErrorOption) *ApiError {
2✔
1334
        eopts := parseOpts(opts)
2✔
1335
        if ae, ok := eopts.err.(*ApiError); ok {
2✔
1336
                return ae
×
1337
        }
×
1338

1339
        e := ApiErrors[JSConsumerInactiveThresholdExcess]
2✔
1340
        args := e.toReplacerArgs([]interface{}{"{limit}", limit})
2✔
1341
        return &ApiError{
2✔
1342
                Code:        e.Code,
2✔
1343
                ErrCode:     e.ErrCode,
2✔
1344
                Description: strings.NewReplacer(args...).Replace(e.Description),
2✔
1345
        }
2✔
1346
}
1347

1348
// NewJSConsumerInvalidDeliverSubjectError creates a new JSConsumerInvalidDeliverSubject error: "invalid push consumer deliver subject"
1349
func NewJSConsumerInvalidDeliverSubjectError(opts ...ErrorOption) *ApiError {
2✔
1350
        eopts := parseOpts(opts)
2✔
1351
        if ae, ok := eopts.err.(*ApiError); ok {
2✔
1352
                return ae
×
1353
        }
×
1354

1355
        return ApiErrors[JSConsumerInvalidDeliverSubject]
2✔
1356
}
1357

1358
// NewJSConsumerInvalidGroupNameError creates a new JSConsumerInvalidGroupNameErr error: "Valid priority group name must match A-Z, a-z, 0-9, -_/=)+ and may not exceed 16 characters"
1359
func NewJSConsumerInvalidGroupNameError(opts ...ErrorOption) *ApiError {
4✔
1360
        eopts := parseOpts(opts)
4✔
1361
        if ae, ok := eopts.err.(*ApiError); ok {
4✔
1362
                return ae
×
1363
        }
×
1364

1365
        return ApiErrors[JSConsumerInvalidGroupNameErr]
4✔
1366
}
1367

1368
// NewJSConsumerInvalidPolicyError creates a new JSConsumerInvalidPolicyErrF error: "{err}"
1369
func NewJSConsumerInvalidPolicyError(err error, opts ...ErrorOption) *ApiError {
10✔
1370
        eopts := parseOpts(opts)
10✔
1371
        if ae, ok := eopts.err.(*ApiError); ok {
10✔
1372
                return ae
×
1373
        }
×
1374

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

1384
// NewJSConsumerInvalidPriorityGroupError creates a new JSConsumerInvalidPriorityGroupErr error: "Provided priority group does not exist for this consumer"
1385
func NewJSConsumerInvalidPriorityGroupError(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[JSConsumerInvalidPriorityGroupErr]
2✔
1392
}
1393

1394
// NewJSConsumerInvalidSamplingError creates a new JSConsumerInvalidSamplingErrF error: "failed to parse consumer sampling configuration: {err}"
1395
func NewJSConsumerInvalidSamplingError(err error, opts ...ErrorOption) *ApiError {
×
1396
        eopts := parseOpts(opts)
×
1397
        if ae, ok := eopts.err.(*ApiError); ok {
×
1398
                return ae
×
1399
        }
×
1400

1401
        e := ApiErrors[JSConsumerInvalidSamplingErrF]
×
1402
        args := e.toReplacerArgs([]interface{}{"{err}", err})
×
1403
        return &ApiError{
×
1404
                Code:        e.Code,
×
1405
                ErrCode:     e.ErrCode,
×
1406
                Description: strings.NewReplacer(args...).Replace(e.Description),
×
1407
        }
×
1408
}
1409

1410
// NewJSConsumerMaxDeliverBackoffError creates a new JSConsumerMaxDeliverBackoffErr error: "max deliver is required to be > length of backoff values"
1411
func NewJSConsumerMaxDeliverBackoffError(opts ...ErrorOption) *ApiError {
3✔
1412
        eopts := parseOpts(opts)
3✔
1413
        if ae, ok := eopts.err.(*ApiError); ok {
3✔
1414
                return ae
×
1415
        }
×
1416

1417
        return ApiErrors[JSConsumerMaxDeliverBackoffErr]
3✔
1418
}
1419

1420
// NewJSConsumerMaxPendingAckExcessError creates a new JSConsumerMaxPendingAckExcessErrF error: "consumer max ack pending exceeds system limit of {limit}"
1421
func NewJSConsumerMaxPendingAckExcessError(limit interface{}, opts ...ErrorOption) *ApiError {
12✔
1422
        eopts := parseOpts(opts)
12✔
1423
        if ae, ok := eopts.err.(*ApiError); ok {
12✔
1424
                return ae
×
1425
        }
×
1426

1427
        e := ApiErrors[JSConsumerMaxPendingAckExcessErrF]
12✔
1428
        args := e.toReplacerArgs([]interface{}{"{limit}", limit})
12✔
1429
        return &ApiError{
12✔
1430
                Code:        e.Code,
12✔
1431
                ErrCode:     e.ErrCode,
12✔
1432
                Description: strings.NewReplacer(args...).Replace(e.Description),
12✔
1433
        }
12✔
1434
}
1435

1436
// NewJSConsumerMaxPendingAckPolicyRequiredError creates a new JSConsumerMaxPendingAckPolicyRequiredErr error: "consumer requires ack policy for max ack pending"
1437
func NewJSConsumerMaxPendingAckPolicyRequiredError(opts ...ErrorOption) *ApiError {
2✔
1438
        eopts := parseOpts(opts)
2✔
1439
        if ae, ok := eopts.err.(*ApiError); ok {
2✔
1440
                return ae
×
1441
        }
×
1442

1443
        return ApiErrors[JSConsumerMaxPendingAckPolicyRequiredErr]
2✔
1444
}
1445

1446
// NewJSConsumerMaxRequestBatchExceededError creates a new JSConsumerMaxRequestBatchExceededF error: "consumer max request batch exceeds server limit of {limit}"
1447
func NewJSConsumerMaxRequestBatchExceededError(limit interface{}, opts ...ErrorOption) *ApiError {
4✔
1448
        eopts := parseOpts(opts)
4✔
1449
        if ae, ok := eopts.err.(*ApiError); ok {
4✔
1450
                return ae
×
1451
        }
×
1452

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

1462
// NewJSConsumerMaxRequestBatchNegativeError creates a new JSConsumerMaxRequestBatchNegativeErr error: "consumer max request batch needs to be > 0"
1463
func NewJSConsumerMaxRequestBatchNegativeError(opts ...ErrorOption) *ApiError {
×
1464
        eopts := parseOpts(opts)
×
1465
        if ae, ok := eopts.err.(*ApiError); ok {
×
1466
                return ae
×
1467
        }
×
1468

1469
        return ApiErrors[JSConsumerMaxRequestBatchNegativeErr]
×
1470
}
1471

1472
// NewJSConsumerMaxRequestExpiresTooSmallError creates a new JSConsumerMaxRequestExpiresTooSmall error: "consumer max request expires needs to be >= 1ms"
1473
func NewJSConsumerMaxRequestExpiresTooSmallError(opts ...ErrorOption) *ApiError {
×
1474
        eopts := parseOpts(opts)
×
1475
        if ae, ok := eopts.err.(*ApiError); ok {
×
1476
                return ae
×
1477
        }
×
1478

1479
        return ApiErrors[JSConsumerMaxRequestExpiresTooSmall]
×
1480
}
1481

1482
// NewJSConsumerMaxWaitingNegativeError creates a new JSConsumerMaxWaitingNegativeErr error: "consumer max waiting needs to be positive"
1483
func NewJSConsumerMaxWaitingNegativeError(opts ...ErrorOption) *ApiError {
×
1484
        eopts := parseOpts(opts)
×
1485
        if ae, ok := eopts.err.(*ApiError); ok {
×
1486
                return ae
×
1487
        }
×
1488

1489
        return ApiErrors[JSConsumerMaxWaitingNegativeErr]
×
1490
}
1491

1492
// NewJSConsumerMetadataLengthError creates a new JSConsumerMetadataLengthErrF error: "consumer metadata exceeds maximum size of {limit}"
1493
func NewJSConsumerMetadataLengthError(limit interface{}, opts ...ErrorOption) *ApiError {
1✔
1494
        eopts := parseOpts(opts)
1✔
1495
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
1496
                return ae
×
1497
        }
×
1498

1499
        e := ApiErrors[JSConsumerMetadataLengthErrF]
1✔
1500
        args := e.toReplacerArgs([]interface{}{"{limit}", limit})
1✔
1501
        return &ApiError{
1✔
1502
                Code:        e.Code,
1✔
1503
                ErrCode:     e.ErrCode,
1✔
1504
                Description: strings.NewReplacer(args...).Replace(e.Description),
1✔
1505
        }
1✔
1506
}
1507

1508
// NewJSConsumerMultipleFiltersNotAllowedError creates a new JSConsumerMultipleFiltersNotAllowed error: "consumer with multiple subject filters cannot use subject based API"
1509
func NewJSConsumerMultipleFiltersNotAllowedError(opts ...ErrorOption) *ApiError {
1✔
1510
        eopts := parseOpts(opts)
1✔
1511
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
1512
                return ae
×
1513
        }
×
1514

1515
        return ApiErrors[JSConsumerMultipleFiltersNotAllowed]
1✔
1516
}
1517

1518
// NewJSConsumerNameContainsPathSeparatorsError creates a new JSConsumerNameContainsPathSeparatorsErr error: "Consumer name can not contain path separators"
1519
func NewJSConsumerNameContainsPathSeparatorsError(opts ...ErrorOption) *ApiError {
8✔
1520
        eopts := parseOpts(opts)
8✔
1521
        if ae, ok := eopts.err.(*ApiError); ok {
8✔
1522
                return ae
×
1523
        }
×
1524

1525
        return ApiErrors[JSConsumerNameContainsPathSeparatorsErr]
8✔
1526
}
1527

1528
// NewJSConsumerNameExistError creates a new JSConsumerNameExistErr error: "consumer name already in use"
1529
func NewJSConsumerNameExistError(opts ...ErrorOption) *ApiError {
2✔
1530
        eopts := parseOpts(opts)
2✔
1531
        if ae, ok := eopts.err.(*ApiError); ok {
2✔
1532
                return ae
×
1533
        }
×
1534

1535
        return ApiErrors[JSConsumerNameExistErr]
2✔
1536
}
1537

1538
// NewJSConsumerNameTooLongError creates a new JSConsumerNameTooLongErrF error: "consumer name is too long, maximum allowed is {max}"
1539
func NewJSConsumerNameTooLongError(max interface{}, opts ...ErrorOption) *ApiError {
×
1540
        eopts := parseOpts(opts)
×
1541
        if ae, ok := eopts.err.(*ApiError); ok {
×
1542
                return ae
×
1543
        }
×
1544

1545
        e := ApiErrors[JSConsumerNameTooLongErrF]
×
1546
        args := e.toReplacerArgs([]interface{}{"{max}", max})
×
1547
        return &ApiError{
×
1548
                Code:        e.Code,
×
1549
                ErrCode:     e.ErrCode,
×
1550
                Description: strings.NewReplacer(args...).Replace(e.Description),
×
1551
        }
×
1552
}
1553

1554
// NewJSConsumerNotFoundError creates a new JSConsumerNotFoundErr error: "consumer not found"
1555
func NewJSConsumerNotFoundError(opts ...ErrorOption) *ApiError {
2,773✔
1556
        eopts := parseOpts(opts)
2,773✔
1557
        if ae, ok := eopts.err.(*ApiError); ok {
2,773✔
1558
                return ae
×
1559
        }
×
1560

1561
        return ApiErrors[JSConsumerNotFoundErr]
2,773✔
1562
}
1563

1564
// NewJSConsumerOfflineError creates a new JSConsumerOfflineErr error: "consumer is offline"
1565
func NewJSConsumerOfflineError(opts ...ErrorOption) *ApiError {
6✔
1566
        eopts := parseOpts(opts)
6✔
1567
        if ae, ok := eopts.err.(*ApiError); ok {
6✔
1568
                return ae
×
1569
        }
×
1570

1571
        return ApiErrors[JSConsumerOfflineErr]
6✔
1572
}
1573

1574
// NewJSConsumerOfflineReasonError creates a new JSConsumerOfflineReasonErrF error: "consumer is offline: {err}"
1575
func NewJSConsumerOfflineReasonError(err error, opts ...ErrorOption) *ApiError {
24✔
1576
        eopts := parseOpts(opts)
24✔
1577
        if ae, ok := eopts.err.(*ApiError); ok {
24✔
1578
                return ae
×
1579
        }
×
1580

1581
        e := ApiErrors[JSConsumerOfflineReasonErrF]
24✔
1582
        args := e.toReplacerArgs([]interface{}{"{err}", err})
24✔
1583
        return &ApiError{
24✔
1584
                Code:        e.Code,
24✔
1585
                ErrCode:     e.ErrCode,
24✔
1586
                Description: strings.NewReplacer(args...).Replace(e.Description),
24✔
1587
        }
24✔
1588
}
1589

1590
// NewJSConsumerOnMappedError creates a new JSConsumerOnMappedErr error: "consumer direct on a mapped consumer"
1591
func NewJSConsumerOnMappedError(opts ...ErrorOption) *ApiError {
×
1592
        eopts := parseOpts(opts)
×
1593
        if ae, ok := eopts.err.(*ApiError); ok {
×
1594
                return ae
×
1595
        }
×
1596

1597
        return ApiErrors[JSConsumerOnMappedErr]
×
1598
}
1599

1600
// NewJSConsumerOverlappingSubjectFiltersError creates a new JSConsumerOverlappingSubjectFilters error: "consumer subject filters cannot overlap"
1601
func NewJSConsumerOverlappingSubjectFiltersError(opts ...ErrorOption) *ApiError {
1✔
1602
        eopts := parseOpts(opts)
1✔
1603
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
1604
                return ae
×
1605
        }
×
1606

1607
        return ApiErrors[JSConsumerOverlappingSubjectFilters]
1✔
1608
}
1609

1610
// NewJSConsumerPinnedTTLWithoutPriorityPolicyNoneError creates a new JSConsumerPinnedTTLWithoutPriorityPolicyNone error: "PinnedTTL cannot be set when PriorityPolicy is none"
1611
func NewJSConsumerPinnedTTLWithoutPriorityPolicyNoneError(opts ...ErrorOption) *ApiError {
1✔
1612
        eopts := parseOpts(opts)
1✔
1613
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
1614
                return ae
×
1615
        }
×
1616

1617
        return ApiErrors[JSConsumerPinnedTTLWithoutPriorityPolicyNone]
1✔
1618
}
1619

1620
// NewJSConsumerPriorityGroupWithPolicyNoneError creates a new JSConsumerPriorityGroupWithPolicyNone error: "consumer can not have priority groups when policy is none"
1621
func NewJSConsumerPriorityGroupWithPolicyNoneError(opts ...ErrorOption) *ApiError {
1✔
1622
        eopts := parseOpts(opts)
1✔
1623
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
1624
                return ae
×
1625
        }
×
1626

1627
        return ApiErrors[JSConsumerPriorityGroupWithPolicyNone]
1✔
1628
}
1629

1630
// NewJSConsumerPriorityPolicyWithoutGroupError creates a new JSConsumerPriorityPolicyWithoutGroup error: "Setting PriorityPolicy requires at least one PriorityGroup to be set"
1631
func NewJSConsumerPriorityPolicyWithoutGroupError(opts ...ErrorOption) *ApiError {
4✔
1632
        eopts := parseOpts(opts)
4✔
1633
        if ae, ok := eopts.err.(*ApiError); ok {
4✔
1634
                return ae
×
1635
        }
×
1636

1637
        return ApiErrors[JSConsumerPriorityPolicyWithoutGroup]
4✔
1638
}
1639

1640
// NewJSConsumerPullNotDurableError creates a new JSConsumerPullNotDurableErr error: "consumer in pull mode requires a durable name"
1641
func NewJSConsumerPullNotDurableError(opts ...ErrorOption) *ApiError {
×
1642
        eopts := parseOpts(opts)
×
1643
        if ae, ok := eopts.err.(*ApiError); ok {
×
1644
                return ae
×
1645
        }
×
1646

1647
        return ApiErrors[JSConsumerPullNotDurableErr]
×
1648
}
1649

1650
// NewJSConsumerPullRequiresAckError creates a new JSConsumerPullRequiresAckErr error: "consumer in pull mode requires explicit ack policy on workqueue stream"
1651
func NewJSConsumerPullRequiresAckError(opts ...ErrorOption) *ApiError {
6✔
1652
        eopts := parseOpts(opts)
6✔
1653
        if ae, ok := eopts.err.(*ApiError); ok {
6✔
1654
                return ae
×
1655
        }
×
1656

1657
        return ApiErrors[JSConsumerPullRequiresAckErr]
6✔
1658
}
1659

1660
// NewJSConsumerPullWithRateLimitError creates a new JSConsumerPullWithRateLimitErr error: "consumer in pull mode can not have rate limit set"
1661
func NewJSConsumerPullWithRateLimitError(opts ...ErrorOption) *ApiError {
1✔
1662
        eopts := parseOpts(opts)
1✔
1663
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
1664
                return ae
×
1665
        }
×
1666

1667
        return ApiErrors[JSConsumerPullWithRateLimitErr]
1✔
1668
}
1669

1670
// NewJSConsumerPushMaxWaitingError creates a new JSConsumerPushMaxWaitingErr error: "consumer in push mode can not set max waiting"
1671
func NewJSConsumerPushMaxWaitingError(opts ...ErrorOption) *ApiError {
3✔
1672
        eopts := parseOpts(opts)
3✔
1673
        if ae, ok := eopts.err.(*ApiError); ok {
3✔
1674
                return ae
×
1675
        }
×
1676

1677
        return ApiErrors[JSConsumerPushMaxWaitingErr]
3✔
1678
}
1679

1680
// NewJSConsumerPushWithPriorityGroupError creates a new JSConsumerPushWithPriorityGroupErr error: "priority groups can not be used with push consumers"
1681
func NewJSConsumerPushWithPriorityGroupError(opts ...ErrorOption) *ApiError {
1✔
1682
        eopts := parseOpts(opts)
1✔
1683
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
1684
                return ae
×
1685
        }
×
1686

1687
        return ApiErrors[JSConsumerPushWithPriorityGroupErr]
1✔
1688
}
1689

1690
// NewJSConsumerReplacementWithDifferentNameError creates a new JSConsumerReplacementWithDifferentNameErr error: "consumer replacement durable config not the same"
1691
func NewJSConsumerReplacementWithDifferentNameError(opts ...ErrorOption) *ApiError {
×
1692
        eopts := parseOpts(opts)
×
1693
        if ae, ok := eopts.err.(*ApiError); ok {
×
1694
                return ae
×
1695
        }
×
1696

1697
        return ApiErrors[JSConsumerReplacementWithDifferentNameErr]
×
1698
}
1699

1700
// NewJSConsumerReplayPolicyInvalidError creates a new JSConsumerReplayPolicyInvalidErr error: "consumer replay policy invalid"
1701
func NewJSConsumerReplayPolicyInvalidError(opts ...ErrorOption) *ApiError {
2✔
1702
        eopts := parseOpts(opts)
2✔
1703
        if ae, ok := eopts.err.(*ApiError); ok {
2✔
1704
                return ae
×
1705
        }
×
1706

1707
        return ApiErrors[JSConsumerReplayPolicyInvalidErr]
2✔
1708
}
1709

1710
// NewJSConsumerReplicasExceedsStreamError creates a new JSConsumerReplicasExceedsStream error: "consumer config replica count exceeds parent stream"
1711
func NewJSConsumerReplicasExceedsStreamError(opts ...ErrorOption) *ApiError {
1✔
1712
        eopts := parseOpts(opts)
1✔
1713
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
1714
                return ae
×
1715
        }
×
1716

1717
        return ApiErrors[JSConsumerReplicasExceedsStream]
1✔
1718
}
1719

1720
// NewJSConsumerReplicasShouldMatchStreamError creates a new JSConsumerReplicasShouldMatchStream error: "consumer config replicas must match interest retention stream's replicas"
1721
func NewJSConsumerReplicasShouldMatchStreamError(opts ...ErrorOption) *ApiError {
2✔
1722
        eopts := parseOpts(opts)
2✔
1723
        if ae, ok := eopts.err.(*ApiError); ok {
2✔
1724
                return ae
×
1725
        }
×
1726

1727
        return ApiErrors[JSConsumerReplicasShouldMatchStream]
2✔
1728
}
1729

1730
// NewJSConsumerSmallHeartbeatError creates a new JSConsumerSmallHeartbeatErr error: "consumer idle heartbeat needs to be >= 100ms"
1731
func NewJSConsumerSmallHeartbeatError(opts ...ErrorOption) *ApiError {
1✔
1732
        eopts := parseOpts(opts)
1✔
1733
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
1734
                return ae
×
1735
        }
×
1736

1737
        return ApiErrors[JSConsumerSmallHeartbeatErr]
1✔
1738
}
1739

1740
// NewJSConsumerStoreFailedError creates a new JSConsumerStoreFailedErrF error: "error creating store for consumer: {err}"
1741
func NewJSConsumerStoreFailedError(err error, opts ...ErrorOption) *ApiError {
8✔
1742
        eopts := parseOpts(opts)
8✔
1743
        if ae, ok := eopts.err.(*ApiError); ok {
8✔
1744
                return ae
×
1745
        }
×
1746

1747
        e := ApiErrors[JSConsumerStoreFailedErrF]
8✔
1748
        args := e.toReplacerArgs([]interface{}{"{err}", err})
8✔
1749
        return &ApiError{
8✔
1750
                Code:        e.Code,
8✔
1751
                ErrCode:     e.ErrCode,
8✔
1752
                Description: strings.NewReplacer(args...).Replace(e.Description),
8✔
1753
        }
8✔
1754
}
1755

1756
// NewJSConsumerWQConsumerNotDeliverAllError creates a new JSConsumerWQConsumerNotDeliverAllErr error: "consumer must be deliver all on workqueue stream"
1757
func NewJSConsumerWQConsumerNotDeliverAllError(opts ...ErrorOption) *ApiError {
×
1758
        eopts := parseOpts(opts)
×
1759
        if ae, ok := eopts.err.(*ApiError); ok {
×
1760
                return ae
×
1761
        }
×
1762

1763
        return ApiErrors[JSConsumerWQConsumerNotDeliverAllErr]
×
1764
}
1765

1766
// NewJSConsumerWQConsumerNotUniqueError creates a new JSConsumerWQConsumerNotUniqueErr error: "filtered consumer not unique on workqueue stream"
1767
func NewJSConsumerWQConsumerNotUniqueError(opts ...ErrorOption) *ApiError {
11✔
1768
        eopts := parseOpts(opts)
11✔
1769
        if ae, ok := eopts.err.(*ApiError); ok {
11✔
1770
                return ae
×
1771
        }
×
1772

1773
        return ApiErrors[JSConsumerWQConsumerNotUniqueErr]
11✔
1774
}
1775

1776
// NewJSConsumerWQMultipleUnfilteredError creates a new JSConsumerWQMultipleUnfilteredErr error: "multiple non-filtered consumers not allowed on workqueue stream"
1777
func NewJSConsumerWQMultipleUnfilteredError(opts ...ErrorOption) *ApiError {
2✔
1778
        eopts := parseOpts(opts)
2✔
1779
        if ae, ok := eopts.err.(*ApiError); ok {
2✔
1780
                return ae
×
1781
        }
×
1782

1783
        return ApiErrors[JSConsumerWQMultipleUnfilteredErr]
2✔
1784
}
1785

1786
// NewJSConsumerWQRequiresExplicitAckError creates a new JSConsumerWQRequiresExplicitAckErr error: "workqueue stream requires explicit ack"
1787
func NewJSConsumerWQRequiresExplicitAckError(opts ...ErrorOption) *ApiError {
×
1788
        eopts := parseOpts(opts)
×
1789
        if ae, ok := eopts.err.(*ApiError); ok {
×
1790
                return ae
×
1791
        }
×
1792

1793
        return ApiErrors[JSConsumerWQRequiresExplicitAckErr]
×
1794
}
1795

1796
// NewJSConsumerWithFlowControlNeedsHeartbeatsError creates a new JSConsumerWithFlowControlNeedsHeartbeats error: "consumer with flow control also needs heartbeats"
1797
func NewJSConsumerWithFlowControlNeedsHeartbeatsError(opts ...ErrorOption) *ApiError {
4✔
1798
        eopts := parseOpts(opts)
4✔
1799
        if ae, ok := eopts.err.(*ApiError); ok {
4✔
1800
                return ae
×
1801
        }
×
1802

1803
        return ApiErrors[JSConsumerWithFlowControlNeedsHeartbeats]
4✔
1804
}
1805

1806
// NewJSInsufficientResourcesError creates a new JSInsufficientResourcesErr error: "insufficient resources"
1807
func NewJSInsufficientResourcesError(opts ...ErrorOption) *ApiError {
11✔
1808
        eopts := parseOpts(opts)
11✔
1809
        if ae, ok := eopts.err.(*ApiError); ok {
11✔
1810
                return ae
×
1811
        }
×
1812

1813
        return ApiErrors[JSInsufficientResourcesErr]
11✔
1814
}
1815

1816
// NewJSInvalidJSONError creates a new JSInvalidJSONErr error: "invalid JSON: {err}"
1817
func NewJSInvalidJSONError(err error, opts ...ErrorOption) *ApiError {
10✔
1818
        eopts := parseOpts(opts)
10✔
1819
        if ae, ok := eopts.err.(*ApiError); ok {
10✔
1820
                return ae
×
1821
        }
×
1822

1823
        e := ApiErrors[JSInvalidJSONErr]
10✔
1824
        args := e.toReplacerArgs([]interface{}{"{err}", err})
10✔
1825
        return &ApiError{
10✔
1826
                Code:        e.Code,
10✔
1827
                ErrCode:     e.ErrCode,
10✔
1828
                Description: strings.NewReplacer(args...).Replace(e.Description),
10✔
1829
        }
10✔
1830
}
1831

1832
// NewJSMaximumConsumersLimitError creates a new JSMaximumConsumersLimitErr error: "maximum consumers limit reached"
1833
func NewJSMaximumConsumersLimitError(opts ...ErrorOption) *ApiError {
29✔
1834
        eopts := parseOpts(opts)
29✔
1835
        if ae, ok := eopts.err.(*ApiError); ok {
29✔
1836
                return ae
×
1837
        }
×
1838

1839
        return ApiErrors[JSMaximumConsumersLimitErr]
29✔
1840
}
1841

1842
// NewJSMaximumStreamsLimitError creates a new JSMaximumStreamsLimitErr error: "maximum number of streams reached"
1843
func NewJSMaximumStreamsLimitError(opts ...ErrorOption) *ApiError {
16✔
1844
        eopts := parseOpts(opts)
16✔
1845
        if ae, ok := eopts.err.(*ApiError); ok {
16✔
1846
                return ae
×
1847
        }
×
1848

1849
        return ApiErrors[JSMaximumStreamsLimitErr]
16✔
1850
}
1851

1852
// NewJSMemoryResourcesExceededError creates a new JSMemoryResourcesExceededErr error: "insufficient memory resources available"
1853
func NewJSMemoryResourcesExceededError(opts ...ErrorOption) *ApiError {
4✔
1854
        eopts := parseOpts(opts)
4✔
1855
        if ae, ok := eopts.err.(*ApiError); ok {
4✔
1856
                return ae
×
1857
        }
×
1858

1859
        return ApiErrors[JSMemoryResourcesExceededErr]
4✔
1860
}
1861

1862
// NewJSMessageCounterBrokenError creates a new JSMessageCounterBrokenErr error: "message counter is broken"
1863
func NewJSMessageCounterBrokenError(opts ...ErrorOption) *ApiError {
4✔
1864
        eopts := parseOpts(opts)
4✔
1865
        if ae, ok := eopts.err.(*ApiError); ok {
4✔
1866
                return ae
×
1867
        }
×
1868

1869
        return ApiErrors[JSMessageCounterBrokenErr]
4✔
1870
}
1871

1872
// NewJSMessageIncrDisabledError creates a new JSMessageIncrDisabledErr error: "message counters is disabled"
1873
func NewJSMessageIncrDisabledError(opts ...ErrorOption) *ApiError {
4✔
1874
        eopts := parseOpts(opts)
4✔
1875
        if ae, ok := eopts.err.(*ApiError); ok {
4✔
1876
                return ae
×
1877
        }
×
1878

1879
        return ApiErrors[JSMessageIncrDisabledErr]
4✔
1880
}
1881

1882
// NewJSMessageIncrInvalidError creates a new JSMessageIncrInvalidErr error: "message counter increment is invalid"
1883
func NewJSMessageIncrInvalidError(opts ...ErrorOption) *ApiError {
24✔
1884
        eopts := parseOpts(opts)
24✔
1885
        if ae, ok := eopts.err.(*ApiError); ok {
24✔
1886
                return ae
×
1887
        }
×
1888

1889
        return ApiErrors[JSMessageIncrInvalidErr]
24✔
1890
}
1891

1892
// NewJSMessageIncrMissingError creates a new JSMessageIncrMissingErr error: "message counter increment is missing"
1893
func NewJSMessageIncrMissingError(opts ...ErrorOption) *ApiError {
8✔
1894
        eopts := parseOpts(opts)
8✔
1895
        if ae, ok := eopts.err.(*ApiError); ok {
8✔
1896
                return ae
×
1897
        }
×
1898

1899
        return ApiErrors[JSMessageIncrMissingErr]
8✔
1900
}
1901

1902
// NewJSMessageIncrPayloadError creates a new JSMessageIncrPayloadErr error: "message counter has payload"
1903
func NewJSMessageIncrPayloadError(opts ...ErrorOption) *ApiError {
4✔
1904
        eopts := parseOpts(opts)
4✔
1905
        if ae, ok := eopts.err.(*ApiError); ok {
4✔
1906
                return ae
×
1907
        }
×
1908

1909
        return ApiErrors[JSMessageIncrPayloadErr]
4✔
1910
}
1911

1912
// NewJSMessageSchedulesDisabledError creates a new JSMessageSchedulesDisabledErr error: "message schedules is disabled"
1913
func NewJSMessageSchedulesDisabledError(opts ...ErrorOption) *ApiError {
20✔
1914
        eopts := parseOpts(opts)
20✔
1915
        if ae, ok := eopts.err.(*ApiError); ok {
20✔
1916
                return ae
×
1917
        }
×
1918

1919
        return ApiErrors[JSMessageSchedulesDisabledErr]
20✔
1920
}
1921

1922
// NewJSMessageSchedulesPatternInvalidError creates a new JSMessageSchedulesPatternInvalidErr error: "message schedules pattern is invalid"
1923
func NewJSMessageSchedulesPatternInvalidError(opts ...ErrorOption) *ApiError {
15✔
1924
        eopts := parseOpts(opts)
15✔
1925
        if ae, ok := eopts.err.(*ApiError); ok {
15✔
1926
                return ae
×
1927
        }
×
1928

1929
        return ApiErrors[JSMessageSchedulesPatternInvalidErr]
15✔
1930
}
1931

1932
// NewJSMessageSchedulesRollupInvalidError creates a new JSMessageSchedulesRollupInvalidErr error: "message schedules invalid rollup"
1933
func NewJSMessageSchedulesRollupInvalidError(opts ...ErrorOption) *ApiError {
8✔
1934
        eopts := parseOpts(opts)
8✔
1935
        if ae, ok := eopts.err.(*ApiError); ok {
8✔
1936
                return ae
×
1937
        }
×
1938

1939
        return ApiErrors[JSMessageSchedulesRollupInvalidErr]
8✔
1940
}
1941

1942
// NewJSMessageSchedulesTTLInvalidError creates a new JSMessageSchedulesTTLInvalidErr error: "message schedules invalid per-message TTL"
1943
func NewJSMessageSchedulesTTLInvalidError(opts ...ErrorOption) *ApiError {
10✔
1944
        eopts := parseOpts(opts)
10✔
1945
        if ae, ok := eopts.err.(*ApiError); ok {
10✔
1946
                return ae
×
1947
        }
×
1948

1949
        return ApiErrors[JSMessageSchedulesTTLInvalidErr]
10✔
1950
}
1951

1952
// NewJSMessageSchedulesTargetInvalidError creates a new JSMessageSchedulesTargetInvalidErr error: "message schedules target is invalid"
1953
func NewJSMessageSchedulesTargetInvalidError(opts ...ErrorOption) *ApiError {
30✔
1954
        eopts := parseOpts(opts)
30✔
1955
        if ae, ok := eopts.err.(*ApiError); ok {
30✔
1956
                return ae
×
1957
        }
×
1958

1959
        return ApiErrors[JSMessageSchedulesTargetInvalidErr]
30✔
1960
}
1961

1962
// NewJSMessageTTLDisabledError creates a new JSMessageTTLDisabledErr error: "per-message TTL is disabled"
1963
func NewJSMessageTTLDisabledError(opts ...ErrorOption) *ApiError {
16✔
1964
        eopts := parseOpts(opts)
16✔
1965
        if ae, ok := eopts.err.(*ApiError); ok {
16✔
1966
                return ae
×
1967
        }
×
1968

1969
        return ApiErrors[JSMessageTTLDisabledErr]
16✔
1970
}
1971

1972
// NewJSMessageTTLInvalidError creates a new JSMessageTTLInvalidErr error: "invalid per-message TTL"
1973
func NewJSMessageTTLInvalidError(opts ...ErrorOption) *ApiError {
23✔
1974
        eopts := parseOpts(opts)
23✔
1975
        if ae, ok := eopts.err.(*ApiError); ok {
23✔
1976
                return ae
×
1977
        }
×
1978

1979
        return ApiErrors[JSMessageTTLInvalidErr]
23✔
1980
}
1981

1982
// NewJSMirrorConsumerSetupFailedError creates a new JSMirrorConsumerSetupFailedErrF error: "{err}"
1983
func NewJSMirrorConsumerSetupFailedError(err error, opts ...ErrorOption) *ApiError {
×
1984
        eopts := parseOpts(opts)
×
1985
        if ae, ok := eopts.err.(*ApiError); ok {
×
1986
                return ae
×
1987
        }
×
1988

1989
        e := ApiErrors[JSMirrorConsumerSetupFailedErrF]
×
1990
        args := e.toReplacerArgs([]interface{}{"{err}", err})
×
1991
        return &ApiError{
×
1992
                Code:        e.Code,
×
1993
                ErrCode:     e.ErrCode,
×
1994
                Description: strings.NewReplacer(args...).Replace(e.Description),
×
1995
        }
×
1996
}
1997

1998
// NewJSMirrorInvalidStreamNameError creates a new JSMirrorInvalidStreamName error: "mirrored stream name is invalid"
1999
func NewJSMirrorInvalidStreamNameError(opts ...ErrorOption) *ApiError {
×
2000
        eopts := parseOpts(opts)
×
2001
        if ae, ok := eopts.err.(*ApiError); ok {
×
2002
                return ae
×
2003
        }
×
2004

2005
        return ApiErrors[JSMirrorInvalidStreamName]
×
2006
}
2007

2008
// NewJSMirrorInvalidSubjectFilterError creates a new JSMirrorInvalidSubjectFilter error: "mirror transform source: {err}"
2009
func NewJSMirrorInvalidSubjectFilterError(err error, opts ...ErrorOption) *ApiError {
2✔
2010
        eopts := parseOpts(opts)
2✔
2011
        if ae, ok := eopts.err.(*ApiError); ok {
2✔
2012
                return ae
×
2013
        }
×
2014

2015
        e := ApiErrors[JSMirrorInvalidSubjectFilter]
2✔
2016
        args := e.toReplacerArgs([]interface{}{"{err}", err})
2✔
2017
        return &ApiError{
2✔
2018
                Code:        e.Code,
2✔
2019
                ErrCode:     e.ErrCode,
2✔
2020
                Description: strings.NewReplacer(args...).Replace(e.Description),
2✔
2021
        }
2✔
2022
}
2023

2024
// NewJSMirrorInvalidTransformDestinationError creates a new JSMirrorInvalidTransformDestination error: "mirror transform: {err}"
2025
func NewJSMirrorInvalidTransformDestinationError(err error, opts ...ErrorOption) *ApiError {
2✔
2026
        eopts := parseOpts(opts)
2✔
2027
        if ae, ok := eopts.err.(*ApiError); ok {
2✔
2028
                return ae
×
2029
        }
×
2030

2031
        e := ApiErrors[JSMirrorInvalidTransformDestination]
2✔
2032
        args := e.toReplacerArgs([]interface{}{"{err}", err})
2✔
2033
        return &ApiError{
2✔
2034
                Code:        e.Code,
2✔
2035
                ErrCode:     e.ErrCode,
2✔
2036
                Description: strings.NewReplacer(args...).Replace(e.Description),
2✔
2037
        }
2✔
2038
}
2039

2040
// NewJSMirrorMaxMessageSizeTooBigError creates a new JSMirrorMaxMessageSizeTooBigErr error: "stream mirror must have max message size >= source"
2041
func NewJSMirrorMaxMessageSizeTooBigError(opts ...ErrorOption) *ApiError {
×
2042
        eopts := parseOpts(opts)
×
2043
        if ae, ok := eopts.err.(*ApiError); ok {
×
2044
                return ae
×
2045
        }
×
2046

2047
        return ApiErrors[JSMirrorMaxMessageSizeTooBigErr]
×
2048
}
2049

2050
// NewJSMirrorMultipleFiltersNotAllowedError creates a new JSMirrorMultipleFiltersNotAllowed error: "mirror with multiple subject transforms cannot also have a single subject filter"
2051
func NewJSMirrorMultipleFiltersNotAllowedError(opts ...ErrorOption) *ApiError {
1✔
2052
        eopts := parseOpts(opts)
1✔
2053
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
2054
                return ae
×
2055
        }
×
2056

2057
        return ApiErrors[JSMirrorMultipleFiltersNotAllowed]
1✔
2058
}
2059

2060
// NewJSMirrorOverlappingSubjectFiltersError creates a new JSMirrorOverlappingSubjectFilters error: "mirror subject filters can not overlap"
2061
func NewJSMirrorOverlappingSubjectFiltersError(opts ...ErrorOption) *ApiError {
2✔
2062
        eopts := parseOpts(opts)
2✔
2063
        if ae, ok := eopts.err.(*ApiError); ok {
2✔
2064
                return ae
×
2065
        }
×
2066

2067
        return ApiErrors[JSMirrorOverlappingSubjectFilters]
2✔
2068
}
2069

2070
// NewJSMirrorWithAtomicPublishError creates a new JSMirrorWithAtomicPublishErr error: "stream mirrors can not also use atomic publishing"
2071
func NewJSMirrorWithAtomicPublishError(opts ...ErrorOption) *ApiError {
4✔
2072
        eopts := parseOpts(opts)
4✔
2073
        if ae, ok := eopts.err.(*ApiError); ok {
4✔
2074
                return ae
×
2075
        }
×
2076

2077
        return ApiErrors[JSMirrorWithAtomicPublishErr]
4✔
2078
}
2079

2080
// NewJSMirrorWithCountersError creates a new JSMirrorWithCountersErr error: "stream mirrors can not also calculate counters"
2081
func NewJSMirrorWithCountersError(opts ...ErrorOption) *ApiError {
4✔
2082
        eopts := parseOpts(opts)
4✔
2083
        if ae, ok := eopts.err.(*ApiError); ok {
4✔
2084
                return ae
×
2085
        }
×
2086

2087
        return ApiErrors[JSMirrorWithCountersErr]
4✔
2088
}
2089

2090
// NewJSMirrorWithFirstSeqError creates a new JSMirrorWithFirstSeqErr error: "stream mirrors can not have first sequence configured"
2091
func NewJSMirrorWithFirstSeqError(opts ...ErrorOption) *ApiError {
2✔
2092
        eopts := parseOpts(opts)
2✔
2093
        if ae, ok := eopts.err.(*ApiError); ok {
2✔
2094
                return ae
×
2095
        }
×
2096

2097
        return ApiErrors[JSMirrorWithFirstSeqErr]
2✔
2098
}
2099

2100
// NewJSMirrorWithMsgSchedulesError creates a new JSMirrorWithMsgSchedulesErr error: "stream mirrors can not also schedule messages"
2101
func NewJSMirrorWithMsgSchedulesError(opts ...ErrorOption) *ApiError {
2✔
2102
        eopts := parseOpts(opts)
2✔
2103
        if ae, ok := eopts.err.(*ApiError); ok {
2✔
2104
                return ae
×
2105
        }
×
2106

2107
        return ApiErrors[JSMirrorWithMsgSchedulesErr]
2✔
2108
}
2109

2110
// NewJSMirrorWithSourcesError creates a new JSMirrorWithSourcesErr error: "stream mirrors can not also contain other sources"
2111
func NewJSMirrorWithSourcesError(opts ...ErrorOption) *ApiError {
×
2112
        eopts := parseOpts(opts)
×
2113
        if ae, ok := eopts.err.(*ApiError); ok {
×
2114
                return ae
×
2115
        }
×
2116

2117
        return ApiErrors[JSMirrorWithSourcesErr]
×
2118
}
2119

2120
// NewJSMirrorWithStartSeqAndTimeError creates a new JSMirrorWithStartSeqAndTimeErr error: "stream mirrors can not have both start seq and start time configured"
2121
func NewJSMirrorWithStartSeqAndTimeError(opts ...ErrorOption) *ApiError {
×
2122
        eopts := parseOpts(opts)
×
2123
        if ae, ok := eopts.err.(*ApiError); ok {
×
2124
                return ae
×
2125
        }
×
2126

2127
        return ApiErrors[JSMirrorWithStartSeqAndTimeErr]
×
2128
}
2129

2130
// NewJSMirrorWithSubjectFiltersError creates a new JSMirrorWithSubjectFiltersErr error: "stream mirrors can not contain filtered subjects"
2131
func NewJSMirrorWithSubjectFiltersError(opts ...ErrorOption) *ApiError {
×
2132
        eopts := parseOpts(opts)
×
2133
        if ae, ok := eopts.err.(*ApiError); ok {
×
2134
                return ae
×
2135
        }
×
2136

2137
        return ApiErrors[JSMirrorWithSubjectFiltersErr]
×
2138
}
2139

2140
// NewJSMirrorWithSubjectsError creates a new JSMirrorWithSubjectsErr error: "stream mirrors can not contain subjects"
2141
func NewJSMirrorWithSubjectsError(opts ...ErrorOption) *ApiError {
2✔
2142
        eopts := parseOpts(opts)
2✔
2143
        if ae, ok := eopts.err.(*ApiError); ok {
2✔
2144
                return ae
×
2145
        }
×
2146

2147
        return ApiErrors[JSMirrorWithSubjectsErr]
2✔
2148
}
2149

2150
// NewJSNoAccountError creates a new JSNoAccountErr error: "account not found"
2151
func NewJSNoAccountError(opts ...ErrorOption) *ApiError {
1✔
2152
        eopts := parseOpts(opts)
1✔
2153
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
2154
                return ae
×
2155
        }
×
2156

2157
        return ApiErrors[JSNoAccountErr]
1✔
2158
}
2159

2160
// NewJSNoLimitsError creates a new JSNoLimitsErr error: "no JetStream default or applicable tiered limit present"
2161
func NewJSNoLimitsError(opts ...ErrorOption) *ApiError {
4✔
2162
        eopts := parseOpts(opts)
4✔
2163
        if ae, ok := eopts.err.(*ApiError); ok {
4✔
2164
                return ae
×
2165
        }
×
2166

2167
        return ApiErrors[JSNoLimitsErr]
4✔
2168
}
2169

2170
// NewJSNoMessageFoundError creates a new JSNoMessageFoundErr error: "no message found"
2171
func NewJSNoMessageFoundError(opts ...ErrorOption) *ApiError {
494✔
2172
        eopts := parseOpts(opts)
494✔
2173
        if ae, ok := eopts.err.(*ApiError); ok {
494✔
2174
                return ae
×
2175
        }
×
2176

2177
        return ApiErrors[JSNoMessageFoundErr]
494✔
2178
}
2179

2180
// NewJSNotEmptyRequestError creates a new JSNotEmptyRequestErr error: "expected an empty request payload"
2181
func NewJSNotEmptyRequestError(opts ...ErrorOption) *ApiError {
3✔
2182
        eopts := parseOpts(opts)
3✔
2183
        if ae, ok := eopts.err.(*ApiError); ok {
3✔
2184
                return ae
×
2185
        }
×
2186

2187
        return ApiErrors[JSNotEmptyRequestErr]
3✔
2188
}
2189

2190
// NewJSNotEnabledError creates a new JSNotEnabledErr error: "JetStream not enabled"
2191
func NewJSNotEnabledError(opts ...ErrorOption) *ApiError {
10✔
2192
        eopts := parseOpts(opts)
10✔
2193
        if ae, ok := eopts.err.(*ApiError); ok {
10✔
2194
                return ae
×
2195
        }
×
2196

2197
        return ApiErrors[JSNotEnabledErr]
10✔
2198
}
2199

2200
// NewJSNotEnabledForAccountError creates a new JSNotEnabledForAccountErr error: "JetStream not enabled for account"
2201
func NewJSNotEnabledForAccountError(opts ...ErrorOption) *ApiError {
327✔
2202
        eopts := parseOpts(opts)
327✔
2203
        if ae, ok := eopts.err.(*ApiError); ok {
327✔
2204
                return ae
×
2205
        }
×
2206

2207
        return ApiErrors[JSNotEnabledForAccountErr]
327✔
2208
}
2209

2210
// NewJSPedanticError creates a new JSPedanticErrF error: "pedantic mode: {err}"
2211
func NewJSPedanticError(err error, opts ...ErrorOption) *ApiError {
36✔
2212
        eopts := parseOpts(opts)
36✔
2213
        if ae, ok := eopts.err.(*ApiError); ok {
36✔
2214
                return ae
×
2215
        }
×
2216

2217
        e := ApiErrors[JSPedanticErrF]
36✔
2218
        args := e.toReplacerArgs([]interface{}{"{err}", err})
36✔
2219
        return &ApiError{
36✔
2220
                Code:        e.Code,
36✔
2221
                ErrCode:     e.ErrCode,
36✔
2222
                Description: strings.NewReplacer(args...).Replace(e.Description),
36✔
2223
        }
36✔
2224
}
2225

2226
// NewJSPeerRemapError creates a new JSPeerRemapErr error: "peer remap failed"
2227
func NewJSPeerRemapError(opts ...ErrorOption) *ApiError {
5✔
2228
        eopts := parseOpts(opts)
5✔
2229
        if ae, ok := eopts.err.(*ApiError); ok {
6✔
2230
                return ae
1✔
2231
        }
1✔
2232

2233
        return ApiErrors[JSPeerRemapErr]
4✔
2234
}
2235

2236
// NewJSRaftGeneralError creates a new JSRaftGeneralErrF error: "{err}"
2237
func NewJSRaftGeneralError(err error, opts ...ErrorOption) *ApiError {
×
2238
        eopts := parseOpts(opts)
×
2239
        if ae, ok := eopts.err.(*ApiError); ok {
×
2240
                return ae
×
2241
        }
×
2242

2243
        e := ApiErrors[JSRaftGeneralErrF]
×
2244
        args := e.toReplacerArgs([]interface{}{"{err}", err})
×
2245
        return &ApiError{
×
2246
                Code:        e.Code,
×
2247
                ErrCode:     e.ErrCode,
×
2248
                Description: strings.NewReplacer(args...).Replace(e.Description),
×
2249
        }
×
2250
}
2251

2252
// NewJSReplicasCountCannotBeNegativeError creates a new JSReplicasCountCannotBeNegative error: "replicas count cannot be negative"
2253
func NewJSReplicasCountCannotBeNegativeError(opts ...ErrorOption) *ApiError {
16✔
2254
        eopts := parseOpts(opts)
16✔
2255
        if ae, ok := eopts.err.(*ApiError); ok {
16✔
2256
                return ae
×
2257
        }
×
2258

2259
        return ApiErrors[JSReplicasCountCannotBeNegative]
16✔
2260
}
2261

2262
// NewJSRequiredApiLevelError creates a new JSRequiredApiLevelErr error: "JetStream minimum api level required"
2263
func NewJSRequiredApiLevelError(opts ...ErrorOption) *ApiError {
58✔
2264
        eopts := parseOpts(opts)
58✔
2265
        if ae, ok := eopts.err.(*ApiError); ok {
58✔
2266
                return ae
×
2267
        }
×
2268

2269
        return ApiErrors[JSRequiredApiLevelErr]
58✔
2270
}
2271

2272
// NewJSRestoreSubscribeFailedError creates a new JSRestoreSubscribeFailedErrF error: "JetStream unable to subscribe to restore snapshot {subject}: {err}"
2273
func NewJSRestoreSubscribeFailedError(err error, subject interface{}, opts ...ErrorOption) *ApiError {
1✔
2274
        eopts := parseOpts(opts)
1✔
2275
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
2276
                return ae
×
2277
        }
×
2278

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

2288
// NewJSSequenceNotFoundError creates a new JSSequenceNotFoundErrF error: "sequence {seq} not found"
2289
func NewJSSequenceNotFoundError(seq uint64, opts ...ErrorOption) *ApiError {
1,562✔
2290
        eopts := parseOpts(opts)
1,562✔
2291
        if ae, ok := eopts.err.(*ApiError); ok {
1,562✔
2292
                return ae
×
2293
        }
×
2294

2295
        e := ApiErrors[JSSequenceNotFoundErrF]
1,562✔
2296
        args := e.toReplacerArgs([]interface{}{"{seq}", seq})
1,562✔
2297
        return &ApiError{
1,562✔
2298
                Code:        e.Code,
1,562✔
2299
                ErrCode:     e.ErrCode,
1,562✔
2300
                Description: strings.NewReplacer(args...).Replace(e.Description),
1,562✔
2301
        }
1,562✔
2302
}
2303

2304
// NewJSSnapshotDeliverSubjectInvalidError creates a new JSSnapshotDeliverSubjectInvalidErr error: "deliver subject not valid"
2305
func NewJSSnapshotDeliverSubjectInvalidError(opts ...ErrorOption) *ApiError {
1✔
2306
        eopts := parseOpts(opts)
1✔
2307
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
2308
                return ae
×
2309
        }
×
2310

2311
        return ApiErrors[JSSnapshotDeliverSubjectInvalidErr]
1✔
2312
}
2313

2314
// NewJSSourceConsumerSetupFailedError creates a new JSSourceConsumerSetupFailedErrF error: "{err}"
2315
func NewJSSourceConsumerSetupFailedError(err error, opts ...ErrorOption) *ApiError {
×
2316
        eopts := parseOpts(opts)
×
2317
        if ae, ok := eopts.err.(*ApiError); ok {
×
2318
                return ae
×
2319
        }
×
2320

2321
        e := ApiErrors[JSSourceConsumerSetupFailedErrF]
×
2322
        args := e.toReplacerArgs([]interface{}{"{err}", err})
×
2323
        return &ApiError{
×
2324
                Code:        e.Code,
×
2325
                ErrCode:     e.ErrCode,
×
2326
                Description: strings.NewReplacer(args...).Replace(e.Description),
×
2327
        }
×
2328
}
2329

2330
// NewJSSourceDuplicateDetectedError creates a new JSSourceDuplicateDetected error: "duplicate source configuration detected"
2331
func NewJSSourceDuplicateDetectedError(opts ...ErrorOption) *ApiError {
×
2332
        eopts := parseOpts(opts)
×
2333
        if ae, ok := eopts.err.(*ApiError); ok {
×
2334
                return ae
×
2335
        }
×
2336

2337
        return ApiErrors[JSSourceDuplicateDetected]
×
2338
}
2339

2340
// NewJSSourceInvalidStreamNameError creates a new JSSourceInvalidStreamName error: "sourced stream name is invalid"
2341
func NewJSSourceInvalidStreamNameError(opts ...ErrorOption) *ApiError {
1✔
2342
        eopts := parseOpts(opts)
1✔
2343
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
2344
                return ae
×
2345
        }
×
2346

2347
        return ApiErrors[JSSourceInvalidStreamName]
1✔
2348
}
2349

2350
// NewJSSourceInvalidSubjectFilterError creates a new JSSourceInvalidSubjectFilter error: "source transform source: {err}"
2351
func NewJSSourceInvalidSubjectFilterError(err error, opts ...ErrorOption) *ApiError {
1✔
2352
        eopts := parseOpts(opts)
1✔
2353
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
2354
                return ae
×
2355
        }
×
2356

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

2366
// NewJSSourceInvalidTransformDestinationError creates a new JSSourceInvalidTransformDestination error: "source transform: {err}"
2367
func NewJSSourceInvalidTransformDestinationError(err error, opts ...ErrorOption) *ApiError {
1✔
2368
        eopts := parseOpts(opts)
1✔
2369
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
2370
                return ae
×
2371
        }
×
2372

2373
        e := ApiErrors[JSSourceInvalidTransformDestination]
1✔
2374
        args := e.toReplacerArgs([]interface{}{"{err}", err})
1✔
2375
        return &ApiError{
1✔
2376
                Code:        e.Code,
1✔
2377
                ErrCode:     e.ErrCode,
1✔
2378
                Description: strings.NewReplacer(args...).Replace(e.Description),
1✔
2379
        }
1✔
2380
}
2381

2382
// NewJSSourceMaxMessageSizeTooBigError creates a new JSSourceMaxMessageSizeTooBigErr error: "stream source must have max message size >= target"
2383
func NewJSSourceMaxMessageSizeTooBigError(opts ...ErrorOption) *ApiError {
×
2384
        eopts := parseOpts(opts)
×
2385
        if ae, ok := eopts.err.(*ApiError); ok {
×
2386
                return ae
×
2387
        }
×
2388

2389
        return ApiErrors[JSSourceMaxMessageSizeTooBigErr]
×
2390
}
2391

2392
// NewJSSourceMultipleFiltersNotAllowedError creates a new JSSourceMultipleFiltersNotAllowed error: "source with multiple subject transforms cannot also have a single subject filter"
2393
func NewJSSourceMultipleFiltersNotAllowedError(opts ...ErrorOption) *ApiError {
×
2394
        eopts := parseOpts(opts)
×
2395
        if ae, ok := eopts.err.(*ApiError); ok {
×
2396
                return ae
×
2397
        }
×
2398

2399
        return ApiErrors[JSSourceMultipleFiltersNotAllowed]
×
2400
}
2401

2402
// NewJSSourceOverlappingSubjectFiltersError creates a new JSSourceOverlappingSubjectFilters error: "source filters can not overlap"
2403
func NewJSSourceOverlappingSubjectFiltersError(opts ...ErrorOption) *ApiError {
×
2404
        eopts := parseOpts(opts)
×
2405
        if ae, ok := eopts.err.(*ApiError); ok {
×
2406
                return ae
×
2407
        }
×
2408

2409
        return ApiErrors[JSSourceOverlappingSubjectFilters]
×
2410
}
2411

2412
// NewJSSourceWithMsgSchedulesError creates a new JSSourceWithMsgSchedulesErr error: "stream source can not also schedule messages"
2413
func NewJSSourceWithMsgSchedulesError(opts ...ErrorOption) *ApiError {
2✔
2414
        eopts := parseOpts(opts)
2✔
2415
        if ae, ok := eopts.err.(*ApiError); ok {
2✔
2416
                return ae
×
2417
        }
×
2418

2419
        return ApiErrors[JSSourceWithMsgSchedulesErr]
2✔
2420
}
2421

2422
// NewJSStorageResourcesExceededError creates a new JSStorageResourcesExceededErr error: "insufficient storage resources available"
2423
func NewJSStorageResourcesExceededError(opts ...ErrorOption) *ApiError {
25✔
2424
        eopts := parseOpts(opts)
25✔
2425
        if ae, ok := eopts.err.(*ApiError); ok {
25✔
2426
                return ae
×
2427
        }
×
2428

2429
        return ApiErrors[JSStorageResourcesExceededErr]
25✔
2430
}
2431

2432
// NewJSStreamAssignmentError creates a new JSStreamAssignmentErrF error: "{err}"
2433
func NewJSStreamAssignmentError(err error, opts ...ErrorOption) *ApiError {
×
2434
        eopts := parseOpts(opts)
×
2435
        if ae, ok := eopts.err.(*ApiError); ok {
×
2436
                return ae
×
2437
        }
×
2438

2439
        e := ApiErrors[JSStreamAssignmentErrF]
×
2440
        args := e.toReplacerArgs([]interface{}{"{err}", err})
×
2441
        return &ApiError{
×
2442
                Code:        e.Code,
×
2443
                ErrCode:     e.ErrCode,
×
2444
                Description: strings.NewReplacer(args...).Replace(e.Description),
×
2445
        }
×
2446
}
2447

2448
// NewJSStreamCreateError creates a new JSStreamCreateErrF error: "{err}"
2449
func NewJSStreamCreateError(err error, opts ...ErrorOption) *ApiError {
86✔
2450
        eopts := parseOpts(opts)
86✔
2451
        if ae, ok := eopts.err.(*ApiError); ok {
169✔
2452
                return ae
83✔
2453
        }
83✔
2454

2455
        e := ApiErrors[JSStreamCreateErrF]
3✔
2456
        args := e.toReplacerArgs([]interface{}{"{err}", err})
3✔
2457
        return &ApiError{
3✔
2458
                Code:        e.Code,
3✔
2459
                ErrCode:     e.ErrCode,
3✔
2460
                Description: strings.NewReplacer(args...).Replace(e.Description),
3✔
2461
        }
3✔
2462
}
2463

2464
// NewJSStreamDeleteError creates a new JSStreamDeleteErrF error: "{err}"
2465
func NewJSStreamDeleteError(err error, opts ...ErrorOption) *ApiError {
×
2466
        eopts := parseOpts(opts)
×
2467
        if ae, ok := eopts.err.(*ApiError); ok {
×
2468
                return ae
×
2469
        }
×
2470

2471
        e := ApiErrors[JSStreamDeleteErrF]
×
2472
        args := e.toReplacerArgs([]interface{}{"{err}", err})
×
2473
        return &ApiError{
×
2474
                Code:        e.Code,
×
2475
                ErrCode:     e.ErrCode,
×
2476
                Description: strings.NewReplacer(args...).Replace(e.Description),
×
2477
        }
×
2478
}
2479

2480
// NewJSStreamDuplicateMessageConflictError creates a new JSStreamDuplicateMessageConflict error: "duplicate message id is in process"
2481
func NewJSStreamDuplicateMessageConflictError(opts ...ErrorOption) *ApiError {
30✔
2482
        eopts := parseOpts(opts)
30✔
2483
        if ae, ok := eopts.err.(*ApiError); ok {
30✔
2484
                return ae
×
2485
        }
×
2486

2487
        return ApiErrors[JSStreamDuplicateMessageConflict]
30✔
2488
}
2489

2490
// NewJSStreamExpectedLastSeqPerSubjectInvalidError creates a new JSStreamExpectedLastSeqPerSubjectInvalid error: "missing sequence for expected last sequence per subject"
2491
func NewJSStreamExpectedLastSeqPerSubjectInvalidError(opts ...ErrorOption) *ApiError {
8✔
2492
        eopts := parseOpts(opts)
8✔
2493
        if ae, ok := eopts.err.(*ApiError); ok {
8✔
2494
                return ae
×
2495
        }
×
2496

2497
        return ApiErrors[JSStreamExpectedLastSeqPerSubjectInvalid]
8✔
2498
}
2499

2500
// NewJSStreamExpectedLastSeqPerSubjectNotReadyError creates a new JSStreamExpectedLastSeqPerSubjectNotReady error: "expected last sequence per subject temporarily unavailable"
2501
func NewJSStreamExpectedLastSeqPerSubjectNotReadyError(opts ...ErrorOption) *ApiError {
×
2502
        eopts := parseOpts(opts)
×
2503
        if ae, ok := eopts.err.(*ApiError); ok {
×
2504
                return ae
×
2505
        }
×
2506

2507
        return ApiErrors[JSStreamExpectedLastSeqPerSubjectNotReady]
×
2508
}
2509

2510
// NewJSStreamExternalApiOverlapError creates a new JSStreamExternalApiOverlapErrF error: "stream external api prefix {prefix} must not overlap with {subject}"
2511
func NewJSStreamExternalApiOverlapError(prefix interface{}, subject interface{}, opts ...ErrorOption) *ApiError {
2✔
2512
        eopts := parseOpts(opts)
2✔
2513
        if ae, ok := eopts.err.(*ApiError); ok {
2✔
2514
                return ae
×
2515
        }
×
2516

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

2526
// NewJSStreamExternalDelPrefixOverlapsError creates a new JSStreamExternalDelPrefixOverlapsErrF error: "stream external delivery prefix {prefix} overlaps with stream subject {subject}"
2527
func NewJSStreamExternalDelPrefixOverlapsError(prefix interface{}, subject interface{}, opts ...ErrorOption) *ApiError {
×
2528
        eopts := parseOpts(opts)
×
2529
        if ae, ok := eopts.err.(*ApiError); ok {
×
2530
                return ae
×
2531
        }
×
2532

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

2542
// NewJSStreamGeneralError creates a new JSStreamGeneralErrorF error: "{err}"
2543
func NewJSStreamGeneralError(err error, opts ...ErrorOption) *ApiError {
3✔
2544
        eopts := parseOpts(opts)
3✔
2545
        if ae, ok := eopts.err.(*ApiError); ok {
3✔
2546
                return ae
×
2547
        }
×
2548

2549
        e := ApiErrors[JSStreamGeneralErrorF]
3✔
2550
        args := e.toReplacerArgs([]interface{}{"{err}", err})
3✔
2551
        return &ApiError{
3✔
2552
                Code:        e.Code,
3✔
2553
                ErrCode:     e.ErrCode,
3✔
2554
                Description: strings.NewReplacer(args...).Replace(e.Description),
3✔
2555
        }
3✔
2556
}
2557

2558
// NewJSStreamHeaderExceedsMaximumError creates a new JSStreamHeaderExceedsMaximumErr error: "header size exceeds maximum allowed of 64k"
2559
func NewJSStreamHeaderExceedsMaximumError(opts ...ErrorOption) *ApiError {
1✔
2560
        eopts := parseOpts(opts)
1✔
2561
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
2562
                return ae
×
2563
        }
×
2564

2565
        return ApiErrors[JSStreamHeaderExceedsMaximumErr]
1✔
2566
}
2567

2568
// NewJSStreamInfoMaxSubjectsError creates a new JSStreamInfoMaxSubjectsErr error: "subject details would exceed maximum allowed"
2569
func NewJSStreamInfoMaxSubjectsError(opts ...ErrorOption) *ApiError {
×
2570
        eopts := parseOpts(opts)
×
2571
        if ae, ok := eopts.err.(*ApiError); ok {
×
2572
                return ae
×
2573
        }
×
2574

2575
        return ApiErrors[JSStreamInfoMaxSubjectsErr]
×
2576
}
2577

2578
// NewJSStreamInvalidConfigError creates a new JSStreamInvalidConfigF error: "{err}"
2579
func NewJSStreamInvalidConfigError(err error, opts ...ErrorOption) *ApiError {
165✔
2580
        eopts := parseOpts(opts)
165✔
2581
        if ae, ok := eopts.err.(*ApiError); ok {
188✔
2582
                return ae
23✔
2583
        }
23✔
2584

2585
        e := ApiErrors[JSStreamInvalidConfigF]
142✔
2586
        args := e.toReplacerArgs([]interface{}{"{err}", err})
142✔
2587
        return &ApiError{
142✔
2588
                Code:        e.Code,
142✔
2589
                ErrCode:     e.ErrCode,
142✔
2590
                Description: strings.NewReplacer(args...).Replace(e.Description),
142✔
2591
        }
142✔
2592
}
2593

2594
// NewJSStreamInvalidError creates a new JSStreamInvalidErr error: "stream not valid"
2595
func NewJSStreamInvalidError(opts ...ErrorOption) *ApiError {
×
2596
        eopts := parseOpts(opts)
×
2597
        if ae, ok := eopts.err.(*ApiError); ok {
×
2598
                return ae
×
2599
        }
×
2600

2601
        return ApiErrors[JSStreamInvalidErr]
×
2602
}
2603

2604
// NewJSStreamInvalidExternalDeliverySubjError creates a new JSStreamInvalidExternalDeliverySubjErrF error: "stream external delivery prefix {prefix} must not contain wildcards"
2605
func NewJSStreamInvalidExternalDeliverySubjError(prefix interface{}, opts ...ErrorOption) *ApiError {
×
2606
        eopts := parseOpts(opts)
×
2607
        if ae, ok := eopts.err.(*ApiError); ok {
×
2608
                return ae
×
2609
        }
×
2610

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

2620
// NewJSStreamLimitsError creates a new JSStreamLimitsErrF error: "{err}"
2621
func NewJSStreamLimitsError(err error, opts ...ErrorOption) *ApiError {
8✔
2622
        eopts := parseOpts(opts)
8✔
2623
        if ae, ok := eopts.err.(*ApiError); ok {
16✔
2624
                return ae
8✔
2625
        }
8✔
2626

2627
        e := ApiErrors[JSStreamLimitsErrF]
×
2628
        args := e.toReplacerArgs([]interface{}{"{err}", err})
×
2629
        return &ApiError{
×
2630
                Code:        e.Code,
×
2631
                ErrCode:     e.ErrCode,
×
2632
                Description: strings.NewReplacer(args...).Replace(e.Description),
×
2633
        }
×
2634
}
2635

2636
// NewJSStreamMaxBytesRequiredError creates a new JSStreamMaxBytesRequired error: "account requires a stream config to have max bytes set"
2637
func NewJSStreamMaxBytesRequiredError(opts ...ErrorOption) *ApiError {
3✔
2638
        eopts := parseOpts(opts)
3✔
2639
        if ae, ok := eopts.err.(*ApiError); ok {
3✔
2640
                return ae
×
2641
        }
×
2642

2643
        return ApiErrors[JSStreamMaxBytesRequired]
3✔
2644
}
2645

2646
// NewJSStreamMaxStreamBytesExceededError creates a new JSStreamMaxStreamBytesExceeded error: "stream max bytes exceeds account limit max stream bytes"
2647
func NewJSStreamMaxStreamBytesExceededError(opts ...ErrorOption) *ApiError {
2✔
2648
        eopts := parseOpts(opts)
2✔
2649
        if ae, ok := eopts.err.(*ApiError); ok {
2✔
2650
                return ae
×
2651
        }
×
2652

2653
        return ApiErrors[JSStreamMaxStreamBytesExceeded]
2✔
2654
}
2655

2656
// NewJSStreamMessageExceedsMaximumError creates a new JSStreamMessageExceedsMaximumErr error: "message size exceeds maximum allowed"
2657
func NewJSStreamMessageExceedsMaximumError(opts ...ErrorOption) *ApiError {
19✔
2658
        eopts := parseOpts(opts)
19✔
2659
        if ae, ok := eopts.err.(*ApiError); ok {
19✔
2660
                return ae
×
2661
        }
×
2662

2663
        return ApiErrors[JSStreamMessageExceedsMaximumErr]
19✔
2664
}
2665

2666
// NewJSStreamMinLastSeqError creates a new JSStreamMinLastSeqErr error: "min last sequence"
2667
func NewJSStreamMinLastSeqError(opts ...ErrorOption) *ApiError {
×
2668
        eopts := parseOpts(opts)
×
2669
        if ae, ok := eopts.err.(*ApiError); ok {
×
2670
                return ae
×
2671
        }
×
2672

2673
        return ApiErrors[JSStreamMinLastSeqErr]
×
2674
}
2675

2676
// NewJSStreamMirrorNotUpdatableError creates a new JSStreamMirrorNotUpdatableErr error: "stream mirror configuration can not be updated"
2677
func NewJSStreamMirrorNotUpdatableError(opts ...ErrorOption) *ApiError {
2✔
2678
        eopts := parseOpts(opts)
2✔
2679
        if ae, ok := eopts.err.(*ApiError); ok {
2✔
2680
                return ae
×
2681
        }
×
2682

2683
        return ApiErrors[JSStreamMirrorNotUpdatableErr]
2✔
2684
}
2685

2686
// NewJSStreamMismatchError creates a new JSStreamMismatchErr error: "stream name in subject does not match request"
2687
func NewJSStreamMismatchError(opts ...ErrorOption) *ApiError {
3✔
2688
        eopts := parseOpts(opts)
3✔
2689
        if ae, ok := eopts.err.(*ApiError); ok {
3✔
2690
                return ae
×
2691
        }
×
2692

2693
        return ApiErrors[JSStreamMismatchErr]
3✔
2694
}
2695

2696
// NewJSStreamMoveAndScaleError creates a new JSStreamMoveAndScaleErr error: "can not move and scale a stream in a single update"
2697
func NewJSStreamMoveAndScaleError(opts ...ErrorOption) *ApiError {
4✔
2698
        eopts := parseOpts(opts)
4✔
2699
        if ae, ok := eopts.err.(*ApiError); ok {
4✔
2700
                return ae
×
2701
        }
×
2702

2703
        return ApiErrors[JSStreamMoveAndScaleErr]
4✔
2704
}
2705

2706
// NewJSStreamMoveInProgressError creates a new JSStreamMoveInProgressF error: "stream move already in progress: {msg}"
2707
func NewJSStreamMoveInProgressError(msg interface{}, opts ...ErrorOption) *ApiError {
2✔
2708
        eopts := parseOpts(opts)
2✔
2709
        if ae, ok := eopts.err.(*ApiError); ok {
2✔
2710
                return ae
×
2711
        }
×
2712

2713
        e := ApiErrors[JSStreamMoveInProgressF]
2✔
2714
        args := e.toReplacerArgs([]interface{}{"{msg}", msg})
2✔
2715
        return &ApiError{
2✔
2716
                Code:        e.Code,
2✔
2717
                ErrCode:     e.ErrCode,
2✔
2718
                Description: strings.NewReplacer(args...).Replace(e.Description),
2✔
2719
        }
2✔
2720
}
2721

2722
// NewJSStreamMoveNotInProgressError creates a new JSStreamMoveNotInProgress error: "stream move not in progress"
2723
func NewJSStreamMoveNotInProgressError(opts ...ErrorOption) *ApiError {
×
2724
        eopts := parseOpts(opts)
×
2725
        if ae, ok := eopts.err.(*ApiError); ok {
×
2726
                return ae
×
2727
        }
×
2728

2729
        return ApiErrors[JSStreamMoveNotInProgress]
×
2730
}
2731

2732
// NewJSStreamMsgDeleteFailedError creates a new JSStreamMsgDeleteFailedF error: "{err}"
2733
func NewJSStreamMsgDeleteFailedError(err error, opts ...ErrorOption) *ApiError {
1,859✔
2734
        eopts := parseOpts(opts)
1,859✔
2735
        if ae, ok := eopts.err.(*ApiError); ok {
1,859✔
2736
                return ae
×
2737
        }
×
2738

2739
        e := ApiErrors[JSStreamMsgDeleteFailedF]
1,859✔
2740
        args := e.toReplacerArgs([]interface{}{"{err}", err})
1,859✔
2741
        return &ApiError{
1,859✔
2742
                Code:        e.Code,
1,859✔
2743
                ErrCode:     e.ErrCode,
1,859✔
2744
                Description: strings.NewReplacer(args...).Replace(e.Description),
1,859✔
2745
        }
1,859✔
2746
}
2747

2748
// NewJSStreamNameContainsPathSeparatorsError creates a new JSStreamNameContainsPathSeparatorsErr error: "Stream name can not contain path separators"
2749
func NewJSStreamNameContainsPathSeparatorsError(opts ...ErrorOption) *ApiError {
6✔
2750
        eopts := parseOpts(opts)
6✔
2751
        if ae, ok := eopts.err.(*ApiError); ok {
6✔
2752
                return ae
×
2753
        }
×
2754

2755
        return ApiErrors[JSStreamNameContainsPathSeparatorsErr]
6✔
2756
}
2757

2758
// NewJSStreamNameExistError creates a new JSStreamNameExistErr error: "stream name already in use with a different configuration"
2759
func NewJSStreamNameExistError(opts ...ErrorOption) *ApiError {
10✔
2760
        eopts := parseOpts(opts)
10✔
2761
        if ae, ok := eopts.err.(*ApiError); ok {
10✔
2762
                return ae
×
2763
        }
×
2764

2765
        return ApiErrors[JSStreamNameExistErr]
10✔
2766
}
2767

2768
// NewJSStreamNameExistRestoreFailedError creates a new JSStreamNameExistRestoreFailedErr error: "stream name already in use, cannot restore"
2769
func NewJSStreamNameExistRestoreFailedError(opts ...ErrorOption) *ApiError {
3✔
2770
        eopts := parseOpts(opts)
3✔
2771
        if ae, ok := eopts.err.(*ApiError); ok {
3✔
2772
                return ae
×
2773
        }
×
2774

2775
        return ApiErrors[JSStreamNameExistRestoreFailedErr]
3✔
2776
}
2777

2778
// NewJSStreamNotFoundError creates a new JSStreamNotFoundErr error: "stream not found"
2779
func NewJSStreamNotFoundError(opts ...ErrorOption) *ApiError {
25,480✔
2780
        eopts := parseOpts(opts)
25,480✔
2781
        if ae, ok := eopts.err.(*ApiError); ok {
26,148✔
2782
                return ae
668✔
2783
        }
668✔
2784

2785
        return ApiErrors[JSStreamNotFoundErr]
24,812✔
2786
}
2787

2788
// NewJSStreamNotMatchError creates a new JSStreamNotMatchErr error: "expected stream does not match"
2789
func NewJSStreamNotMatchError(opts ...ErrorOption) *ApiError {
5✔
2790
        eopts := parseOpts(opts)
5✔
2791
        if ae, ok := eopts.err.(*ApiError); ok {
5✔
2792
                return ae
×
2793
        }
×
2794

2795
        return ApiErrors[JSStreamNotMatchErr]
5✔
2796
}
2797

2798
// NewJSStreamOfflineError creates a new JSStreamOfflineErr error: "stream is offline"
2799
func NewJSStreamOfflineError(opts ...ErrorOption) *ApiError {
6✔
2800
        eopts := parseOpts(opts)
6✔
2801
        if ae, ok := eopts.err.(*ApiError); ok {
6✔
2802
                return ae
×
2803
        }
×
2804

2805
        return ApiErrors[JSStreamOfflineErr]
6✔
2806
}
2807

2808
// NewJSStreamOfflineReasonError creates a new JSStreamOfflineReasonErrF error: "stream is offline: {err}"
2809
func NewJSStreamOfflineReasonError(err error, opts ...ErrorOption) *ApiError {
40✔
2810
        eopts := parseOpts(opts)
40✔
2811
        if ae, ok := eopts.err.(*ApiError); ok {
40✔
2812
                return ae
×
2813
        }
×
2814

2815
        e := ApiErrors[JSStreamOfflineReasonErrF]
40✔
2816
        args := e.toReplacerArgs([]interface{}{"{err}", err})
40✔
2817
        return &ApiError{
40✔
2818
                Code:        e.Code,
40✔
2819
                ErrCode:     e.ErrCode,
40✔
2820
                Description: strings.NewReplacer(args...).Replace(e.Description),
40✔
2821
        }
40✔
2822
}
2823

2824
// NewJSStreamPurgeFailedError creates a new JSStreamPurgeFailedF error: "{err}"
2825
func NewJSStreamPurgeFailedError(err error, opts ...ErrorOption) *ApiError {
1✔
2826
        eopts := parseOpts(opts)
1✔
2827
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
2828
                return ae
×
2829
        }
×
2830

2831
        e := ApiErrors[JSStreamPurgeFailedF]
1✔
2832
        args := e.toReplacerArgs([]interface{}{"{err}", err})
1✔
2833
        return &ApiError{
1✔
2834
                Code:        e.Code,
1✔
2835
                ErrCode:     e.ErrCode,
1✔
2836
                Description: strings.NewReplacer(args...).Replace(e.Description),
1✔
2837
        }
1✔
2838
}
2839

2840
// NewJSStreamReplicasNotSupportedError creates a new JSStreamReplicasNotSupportedErr error: "replicas > 1 not supported in non-clustered mode"
2841
func NewJSStreamReplicasNotSupportedError(opts ...ErrorOption) *ApiError {
1✔
2842
        eopts := parseOpts(opts)
1✔
2843
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
2844
                return ae
×
2845
        }
×
2846

2847
        return ApiErrors[JSStreamReplicasNotSupportedErr]
1✔
2848
}
2849

2850
// NewJSStreamReplicasNotUpdatableError creates a new JSStreamReplicasNotUpdatableErr error: "Replicas configuration can not be updated"
2851
func NewJSStreamReplicasNotUpdatableError(opts ...ErrorOption) *ApiError {
×
2852
        eopts := parseOpts(opts)
×
2853
        if ae, ok := eopts.err.(*ApiError); ok {
×
2854
                return ae
×
2855
        }
×
2856

2857
        return ApiErrors[JSStreamReplicasNotUpdatableErr]
×
2858
}
2859

2860
// NewJSStreamRestoreError creates a new JSStreamRestoreErrF error: "restore failed: {err}"
2861
func NewJSStreamRestoreError(err error, opts ...ErrorOption) *ApiError {
7✔
2862
        eopts := parseOpts(opts)
7✔
2863
        if ae, ok := eopts.err.(*ApiError); ok {
9✔
2864
                return ae
2✔
2865
        }
2✔
2866

2867
        e := ApiErrors[JSStreamRestoreErrF]
5✔
2868
        args := e.toReplacerArgs([]interface{}{"{err}", err})
5✔
2869
        return &ApiError{
5✔
2870
                Code:        e.Code,
5✔
2871
                ErrCode:     e.ErrCode,
5✔
2872
                Description: strings.NewReplacer(args...).Replace(e.Description),
5✔
2873
        }
5✔
2874
}
2875

2876
// NewJSStreamRollupFailedError creates a new JSStreamRollupFailedF error: "{err}"
2877
func NewJSStreamRollupFailedError(err error, opts ...ErrorOption) *ApiError {
13✔
2878
        eopts := parseOpts(opts)
13✔
2879
        if ae, ok := eopts.err.(*ApiError); ok {
13✔
2880
                return ae
×
2881
        }
×
2882

2883
        e := ApiErrors[JSStreamRollupFailedF]
13✔
2884
        args := e.toReplacerArgs([]interface{}{"{err}", err})
13✔
2885
        return &ApiError{
13✔
2886
                Code:        e.Code,
13✔
2887
                ErrCode:     e.ErrCode,
13✔
2888
                Description: strings.NewReplacer(args...).Replace(e.Description),
13✔
2889
        }
13✔
2890
}
2891

2892
// NewJSStreamSealedError creates a new JSStreamSealedErr error: "invalid operation on sealed stream"
2893
func NewJSStreamSealedError(opts ...ErrorOption) *ApiError {
10✔
2894
        eopts := parseOpts(opts)
10✔
2895
        if ae, ok := eopts.err.(*ApiError); ok {
10✔
2896
                return ae
×
2897
        }
×
2898

2899
        return ApiErrors[JSStreamSealedErr]
10✔
2900
}
2901

2902
// NewJSStreamSequenceNotMatchError creates a new JSStreamSequenceNotMatchErr error: "expected stream sequence does not match"
2903
func NewJSStreamSequenceNotMatchError(opts ...ErrorOption) *ApiError {
×
2904
        eopts := parseOpts(opts)
×
2905
        if ae, ok := eopts.err.(*ApiError); ok {
×
2906
                return ae
×
2907
        }
×
2908

2909
        return ApiErrors[JSStreamSequenceNotMatchErr]
×
2910
}
2911

2912
// NewJSStreamSnapshotError creates a new JSStreamSnapshotErrF error: "snapshot failed: {err}"
2913
func NewJSStreamSnapshotError(err error, opts ...ErrorOption) *ApiError {
×
2914
        eopts := parseOpts(opts)
×
2915
        if ae, ok := eopts.err.(*ApiError); ok {
×
2916
                return ae
×
2917
        }
×
2918

2919
        e := ApiErrors[JSStreamSnapshotErrF]
×
2920
        args := e.toReplacerArgs([]interface{}{"{err}", err})
×
2921
        return &ApiError{
×
2922
                Code:        e.Code,
×
2923
                ErrCode:     e.ErrCode,
×
2924
                Description: strings.NewReplacer(args...).Replace(e.Description),
×
2925
        }
×
2926
}
2927

2928
// NewJSStreamStoreFailedError creates a new JSStreamStoreFailedF error: "{err}"
2929
func NewJSStreamStoreFailedError(err error, opts ...ErrorOption) *ApiError {
1,031✔
2930
        eopts := parseOpts(opts)
1,031✔
2931
        if ae, ok := eopts.err.(*ApiError); ok {
1,031✔
2932
                return ae
×
2933
        }
×
2934

2935
        e := ApiErrors[JSStreamStoreFailedF]
1,031✔
2936
        args := e.toReplacerArgs([]interface{}{"{err}", err})
1,031✔
2937
        return &ApiError{
1,031✔
2938
                Code:        e.Code,
1,031✔
2939
                ErrCode:     e.ErrCode,
1,031✔
2940
                Description: strings.NewReplacer(args...).Replace(e.Description),
1,031✔
2941
        }
1,031✔
2942
}
2943

2944
// NewJSStreamSubjectOverlapError creates a new JSStreamSubjectOverlapErr error: "subjects overlap with an existing stream"
2945
func NewJSStreamSubjectOverlapError(opts ...ErrorOption) *ApiError {
43✔
2946
        eopts := parseOpts(opts)
43✔
2947
        if ae, ok := eopts.err.(*ApiError); ok {
43✔
2948
                return ae
×
2949
        }
×
2950

2951
        return ApiErrors[JSStreamSubjectOverlapErr]
43✔
2952
}
2953

2954
// NewJSStreamTemplateCreateError creates a new JSStreamTemplateCreateErrF error: "{err}"
2955
func NewJSStreamTemplateCreateError(err error, opts ...ErrorOption) *ApiError {
×
2956
        eopts := parseOpts(opts)
×
2957
        if ae, ok := eopts.err.(*ApiError); ok {
×
2958
                return ae
×
2959
        }
×
2960

2961
        e := ApiErrors[JSStreamTemplateCreateErrF]
×
2962
        args := e.toReplacerArgs([]interface{}{"{err}", err})
×
2963
        return &ApiError{
×
2964
                Code:        e.Code,
×
2965
                ErrCode:     e.ErrCode,
×
2966
                Description: strings.NewReplacer(args...).Replace(e.Description),
×
2967
        }
×
2968
}
2969

2970
// NewJSStreamTemplateDeleteError creates a new JSStreamTemplateDeleteErrF error: "{err}"
2971
func NewJSStreamTemplateDeleteError(err error, opts ...ErrorOption) *ApiError {
1✔
2972
        eopts := parseOpts(opts)
1✔
2973
        if ae, ok := eopts.err.(*ApiError); ok {
2✔
2974
                return ae
1✔
2975
        }
1✔
2976

2977
        e := ApiErrors[JSStreamTemplateDeleteErrF]
×
2978
        args := e.toReplacerArgs([]interface{}{"{err}", err})
×
2979
        return &ApiError{
×
2980
                Code:        e.Code,
×
2981
                ErrCode:     e.ErrCode,
×
2982
                Description: strings.NewReplacer(args...).Replace(e.Description),
×
2983
        }
×
2984
}
2985

2986
// NewJSStreamTemplateNotFoundError creates a new JSStreamTemplateNotFoundErr error: "template not found"
2987
func NewJSStreamTemplateNotFoundError(opts ...ErrorOption) *ApiError {
4✔
2988
        eopts := parseOpts(opts)
4✔
2989
        if ae, ok := eopts.err.(*ApiError); ok {
4✔
2990
                return ae
×
2991
        }
×
2992

2993
        return ApiErrors[JSStreamTemplateNotFoundErr]
4✔
2994
}
2995

2996
// NewJSStreamTooManyRequestsError creates a new JSStreamTooManyRequests error: "too many requests"
2997
func NewJSStreamTooManyRequestsError(opts ...ErrorOption) *ApiError {
141✔
2998
        eopts := parseOpts(opts)
141✔
2999
        if ae, ok := eopts.err.(*ApiError); ok {
141✔
3000
                return ae
×
3001
        }
×
3002

3003
        return ApiErrors[JSStreamTooManyRequests]
141✔
3004
}
3005

3006
// NewJSStreamTransformInvalidDestinationError creates a new JSStreamTransformInvalidDestination error: "stream transform: {err}"
3007
func NewJSStreamTransformInvalidDestinationError(err error, opts ...ErrorOption) *ApiError {
1✔
3008
        eopts := parseOpts(opts)
1✔
3009
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
3010
                return ae
×
3011
        }
×
3012

3013
        e := ApiErrors[JSStreamTransformInvalidDestination]
1✔
3014
        args := e.toReplacerArgs([]interface{}{"{err}", err})
1✔
3015
        return &ApiError{
1✔
3016
                Code:        e.Code,
1✔
3017
                ErrCode:     e.ErrCode,
1✔
3018
                Description: strings.NewReplacer(args...).Replace(e.Description),
1✔
3019
        }
1✔
3020
}
3021

3022
// NewJSStreamTransformInvalidSourceError creates a new JSStreamTransformInvalidSource error: "stream transform source: {err}"
3023
func NewJSStreamTransformInvalidSourceError(err error, opts ...ErrorOption) *ApiError {
1✔
3024
        eopts := parseOpts(opts)
1✔
3025
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
3026
                return ae
×
3027
        }
×
3028

3029
        e := ApiErrors[JSStreamTransformInvalidSource]
1✔
3030
        args := e.toReplacerArgs([]interface{}{"{err}", err})
1✔
3031
        return &ApiError{
1✔
3032
                Code:        e.Code,
1✔
3033
                ErrCode:     e.ErrCode,
1✔
3034
                Description: strings.NewReplacer(args...).Replace(e.Description),
1✔
3035
        }
1✔
3036
}
3037

3038
// NewJSStreamUpdateError creates a new JSStreamUpdateErrF error: "{err}"
3039
func NewJSStreamUpdateError(err error, opts ...ErrorOption) *ApiError {
29✔
3040
        eopts := parseOpts(opts)
29✔
3041
        if ae, ok := eopts.err.(*ApiError); ok {
52✔
3042
                return ae
23✔
3043
        }
23✔
3044

3045
        e := ApiErrors[JSStreamUpdateErrF]
6✔
3046
        args := e.toReplacerArgs([]interface{}{"{err}", err})
6✔
3047
        return &ApiError{
6✔
3048
                Code:        e.Code,
6✔
3049
                ErrCode:     e.ErrCode,
6✔
3050
                Description: strings.NewReplacer(args...).Replace(e.Description),
6✔
3051
        }
6✔
3052
}
3053

3054
// NewJSStreamWrongLastMsgIDError creates a new JSStreamWrongLastMsgIDErrF error: "wrong last msg ID: {id}"
3055
func NewJSStreamWrongLastMsgIDError(id interface{}, opts ...ErrorOption) *ApiError {
5✔
3056
        eopts := parseOpts(opts)
5✔
3057
        if ae, ok := eopts.err.(*ApiError); ok {
5✔
3058
                return ae
×
3059
        }
×
3060

3061
        e := ApiErrors[JSStreamWrongLastMsgIDErrF]
5✔
3062
        args := e.toReplacerArgs([]interface{}{"{id}", id})
5✔
3063
        return &ApiError{
5✔
3064
                Code:        e.Code,
5✔
3065
                ErrCode:     e.ErrCode,
5✔
3066
                Description: strings.NewReplacer(args...).Replace(e.Description),
5✔
3067
        }
5✔
3068
}
3069

3070
// NewJSStreamWrongLastSequenceConstantError creates a new JSStreamWrongLastSequenceConstantErr error: "wrong last sequence"
3071
func NewJSStreamWrongLastSequenceConstantError(opts ...ErrorOption) *ApiError {
24✔
3072
        eopts := parseOpts(opts)
24✔
3073
        if ae, ok := eopts.err.(*ApiError); ok {
24✔
3074
                return ae
×
3075
        }
×
3076

3077
        return ApiErrors[JSStreamWrongLastSequenceConstantErr]
24✔
3078
}
3079

3080
// NewJSStreamWrongLastSequenceError creates a new JSStreamWrongLastSequenceErrF error: "wrong last sequence: {seq}"
3081
func NewJSStreamWrongLastSequenceError(seq uint64, opts ...ErrorOption) *ApiError {
95✔
3082
        eopts := parseOpts(opts)
95✔
3083
        if ae, ok := eopts.err.(*ApiError); ok {
95✔
3084
                return ae
×
3085
        }
×
3086

3087
        e := ApiErrors[JSStreamWrongLastSequenceErrF]
95✔
3088
        args := e.toReplacerArgs([]interface{}{"{seq}", seq})
95✔
3089
        return &ApiError{
95✔
3090
                Code:        e.Code,
95✔
3091
                ErrCode:     e.ErrCode,
95✔
3092
                Description: strings.NewReplacer(args...).Replace(e.Description),
95✔
3093
        }
95✔
3094
}
3095

3096
// NewJSTempStorageFailedError creates a new JSTempStorageFailedErr error: "JetStream unable to open temp storage for restore"
3097
func NewJSTempStorageFailedError(opts ...ErrorOption) *ApiError {
×
3098
        eopts := parseOpts(opts)
×
3099
        if ae, ok := eopts.err.(*ApiError); ok {
×
3100
                return ae
×
3101
        }
×
3102

3103
        return ApiErrors[JSTempStorageFailedErr]
×
3104
}
3105

3106
// NewJSTemplateNameNotMatchSubjectError creates a new JSTemplateNameNotMatchSubjectErr error: "template name in subject does not match request"
3107
func NewJSTemplateNameNotMatchSubjectError(opts ...ErrorOption) *ApiError {
1✔
3108
        eopts := parseOpts(opts)
1✔
3109
        if ae, ok := eopts.err.(*ApiError); ok {
1✔
3110
                return ae
×
3111
        }
×
3112

3113
        return ApiErrors[JSTemplateNameNotMatchSubjectErr]
1✔
3114
}
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