diff --git a/dotnet/src/ZB.MOM.NatsNet.Server/JetStream/JetStreamErrors.GeneratedConstructors.cs b/dotnet/src/ZB.MOM.NatsNet.Server/JetStream/JetStreamErrors.GeneratedConstructors.cs index 53f8ea2..c20c0cb 100644 --- a/dotnet/src/ZB.MOM.NatsNet.Server/JetStream/JetStreamErrors.GeneratedConstructors.cs +++ b/dotnet/src/ZB.MOM.NatsNet.Server/JetStream/JetStreamErrors.GeneratedConstructors.cs @@ -1120,6 +1120,86 @@ public static partial class JsApiErrors return Clone(StreamNameExistRestoreFailed); } + public static JsApiError NewJSStreamNotFoundError(params ErrorOption[] opts) + { + if (ParseOpts(opts) is JsApiError overridden) + return Clone(overridden); + + return Clone(StreamNotFound); + } + + public static JsApiError NewJSStreamNotMatchError(params ErrorOption[] opts) + { + if (ParseOpts(opts) is JsApiError overridden) + return Clone(overridden); + + return Clone(StreamNotMatch); + } + + public static JsApiError NewJSStreamOfflineError(params ErrorOption[] opts) + { + if (ParseOpts(opts) is JsApiError overridden) + return Clone(overridden); + + return Clone(StreamOffline); + } + + public static JsApiError NewJSStreamReplicasNotSupportedError(params ErrorOption[] opts) + { + if (ParseOpts(opts) is JsApiError overridden) + return Clone(overridden); + + return Clone(StreamReplicasNotSupported); + } + + public static JsApiError NewJSStreamReplicasNotUpdatableError(params ErrorOption[] opts) + { + if (ParseOpts(opts) is JsApiError overridden) + return Clone(overridden); + + return Clone(StreamReplicasNotUpdatable); + } + + public static JsApiError NewJSStreamSealedError(params ErrorOption[] opts) + { + if (ParseOpts(opts) is JsApiError overridden) + return Clone(overridden); + + return Clone(StreamSealed); + } + + public static JsApiError NewJSStreamSequenceNotMatchError(params ErrorOption[] opts) + { + if (ParseOpts(opts) is JsApiError overridden) + return Clone(overridden); + + return Clone(StreamSequenceNotMatch); + } + + public static JsApiError NewJSStreamSubjectOverlapError(params ErrorOption[] opts) + { + if (ParseOpts(opts) is JsApiError overridden) + return Clone(overridden); + + return Clone(StreamSubjectOverlap); + } + + public static JsApiError NewJSStreamTemplateNotFoundError(params ErrorOption[] opts) + { + if (ParseOpts(opts) is JsApiError overridden) + return Clone(overridden); + + return Clone(StreamTemplateNotFound); + } + + public static JsApiError NewJSStreamTooManyRequestsError(params ErrorOption[] opts) + { + if (ParseOpts(opts) is JsApiError overridden) + return Clone(overridden); + + return Clone(StreamTooManyRequests); + } + public static JsApiError NewJSAtomicPublishTooLargeBatchError(object? size, params ErrorOption[] opts) { if (ParseOpts(opts) is JsApiError overridden) @@ -1392,6 +1472,78 @@ public static partial class JsApiErrors return NewWithTags(StreamMsgDeleteFailed, "{err}", err); } + public static JsApiError NewJSStreamOfflineReasonError(Exception err, params ErrorOption[] opts) + { + if (ParseOpts(opts) is JsApiError overridden) + return Clone(overridden); + + return NewWithTags(StreamOfflineReason, "{err}", err); + } + + public static JsApiError NewJSStreamPurgeFailedError(Exception err, params ErrorOption[] opts) + { + if (ParseOpts(opts) is JsApiError overridden) + return Clone(overridden); + + return NewWithTags(StreamPurgeFailed, "{err}", err); + } + + public static JsApiError NewJSStreamRollupFailedError(Exception err, params ErrorOption[] opts) + { + if (ParseOpts(opts) is JsApiError overridden) + return Clone(overridden); + + return NewWithTags(StreamRollupFailed, "{err}", err); + } + + public static JsApiError NewJSStreamSnapshotError(Exception err, params ErrorOption[] opts) + { + if (ParseOpts(opts) is JsApiError overridden) + return Clone(overridden); + + return NewWithTags(StreamSnapshot, "{err}", err); + } + + public static JsApiError NewJSStreamStoreFailedError(Exception err, params ErrorOption[] opts) + { + if (ParseOpts(opts) is JsApiError overridden) + return Clone(overridden); + + return NewWithTags(StreamStoreFailed, "{err}", err); + } + + public static JsApiError NewJSStreamTemplateCreateError(Exception err, params ErrorOption[] opts) + { + if (ParseOpts(opts) is JsApiError overridden) + return Clone(overridden); + + return NewWithTags(StreamTemplateCreate, "{err}", err); + } + + public static JsApiError NewJSStreamTemplateDeleteError(Exception err, params ErrorOption[] opts) + { + if (ParseOpts(opts) is JsApiError overridden) + return Clone(overridden); + + return NewWithTags(StreamTemplateDelete, "{err}", err); + } + + public static JsApiError NewJSStreamTransformInvalidDestinationError(Exception err, params ErrorOption[] opts) + { + if (ParseOpts(opts) is JsApiError overridden) + return Clone(overridden); + + return NewWithTags(StreamTransformInvalidDestination, "{err}", err); + } + + public static JsApiError NewJSStreamTransformInvalidSourceError(Exception err, params ErrorOption[] opts) + { + if (ParseOpts(opts) is JsApiError overridden) + return Clone(overridden); + + return NewWithTags(StreamTransformInvalidSource, "{err}", err); + } + public static JsApiError NewJSStreamExternalApiOverlapError(object? prefix, object? subject, params ErrorOption[] opts) { if (ParseOpts(opts) is JsApiError overridden) diff --git a/dotnet/tests/ZB.MOM.NatsNet.Server.Tests/JetStream/JetStreamErrorsGeneratedConstructorsTests.cs b/dotnet/tests/ZB.MOM.NatsNet.Server.Tests/JetStream/JetStreamErrorsGeneratedConstructorsTests.cs index 7c7ed63..1065454 100644 --- a/dotnet/tests/ZB.MOM.NatsNet.Server.Tests/JetStream/JetStreamErrorsGeneratedConstructorsTests.cs +++ b/dotnet/tests/ZB.MOM.NatsNet.Server.Tests/JetStream/JetStreamErrorsGeneratedConstructorsTests.cs @@ -300,4 +300,37 @@ public sealed class JetStreamErrorsGeneratedConstructorsTests fromOverride.Description.ShouldBe(expected.Description); ReferenceEquals(fromOverride, expected).ShouldBeFalse(); } + + [Fact] + public void ConstructorSurface_Group10() + { + JsApiErrors.NewJSStreamNotFoundError().ErrCode.ShouldBe(JsApiErrors.StreamNotFound.ErrCode); + JsApiErrors.NewJSStreamNotMatchError().ErrCode.ShouldBe(JsApiErrors.StreamNotMatch.ErrCode); + JsApiErrors.NewJSStreamOfflineError().ErrCode.ShouldBe(JsApiErrors.StreamOffline.ErrCode); + JsApiErrors.NewJSStreamReplicasNotSupportedError().ErrCode.ShouldBe(JsApiErrors.StreamReplicasNotSupported.ErrCode); + JsApiErrors.NewJSStreamReplicasNotUpdatableError().ErrCode.ShouldBe(JsApiErrors.StreamReplicasNotUpdatable.ErrCode); + JsApiErrors.NewJSStreamSealedError().ErrCode.ShouldBe(JsApiErrors.StreamSealed.ErrCode); + JsApiErrors.NewJSStreamSequenceNotMatchError().ErrCode.ShouldBe(JsApiErrors.StreamSequenceNotMatch.ErrCode); + JsApiErrors.NewJSStreamSubjectOverlapError().ErrCode.ShouldBe(JsApiErrors.StreamSubjectOverlap.ErrCode); + JsApiErrors.NewJSStreamTemplateNotFoundError().ErrCode.ShouldBe(JsApiErrors.StreamTemplateNotFound.ErrCode); + JsApiErrors.NewJSStreamTooManyRequestsError().ErrCode.ShouldBe(JsApiErrors.StreamTooManyRequests.ErrCode); + + JsApiErrors.NewJSStreamOfflineReasonError(new InvalidOperationException("offline reason")).Description.ShouldBe("stream is offline: offline reason"); + JsApiErrors.NewJSStreamPurgeFailedError(new InvalidOperationException("purge failed")).Description.ShouldBe("purge failed"); + JsApiErrors.NewJSStreamRestoreError(new InvalidOperationException("restore failed")).Description.ShouldBe("restore failed: restore failed"); + JsApiErrors.NewJSStreamRollupFailedError(new InvalidOperationException("rollup failed")).Description.ShouldBe("rollup failed"); + JsApiErrors.NewJSStreamSnapshotError(new InvalidOperationException("snapshot failed")).Description.ShouldBe("snapshot failed: snapshot failed"); + JsApiErrors.NewJSStreamStoreFailedError(new InvalidOperationException("store failed")).Description.ShouldBe("store failed"); + JsApiErrors.NewJSStreamTemplateCreateError(new InvalidOperationException("template create failed")).Description.ShouldBe("template create failed"); + JsApiErrors.NewJSStreamTemplateDeleteError(new InvalidOperationException("template delete failed")).Description.ShouldBe("template delete failed"); + JsApiErrors.NewJSStreamTransformInvalidDestinationError(new InvalidOperationException("bad destination")).Description.ShouldBe("stream transform: bad destination"); + JsApiErrors.NewJSStreamTransformInvalidSourceError(new InvalidOperationException("bad source")).Description.ShouldBe("stream transform source: bad source"); + + var expected = new JsApiError { Code = 490, ErrCode = 9099, Description = "override-10" }; + var fromOverride = JsApiErrors.NewJSStreamNotFoundError(JsApiErrors.Unless(expected)); + fromOverride.Code.ShouldBe(expected.Code); + fromOverride.ErrCode.ShouldBe(expected.ErrCode); + fromOverride.Description.ShouldBe(expected.Description); + ReferenceEquals(fromOverride, expected).ShouldBeFalse(); + } } diff --git a/porting.db b/porting.db index 497fd3e..f27c5a4 100644 Binary files a/porting.db and b/porting.db differ diff --git a/tools/generate-jetstream-errors.sh b/tools/generate-jetstream-errors.sh index 4965009..edff050 100755 --- a/tools/generate-jetstream-errors.sh +++ b/tools/generate-jetstream-errors.sh @@ -144,6 +144,16 @@ simple_methods=( "NewJSStreamNameContainsPathSeparatorsError|StreamNameContainsPathSeparators" "NewJSStreamNameExistError|StreamNameExist" "NewJSStreamNameExistRestoreFailedError|StreamNameExistRestoreFailed" + "NewJSStreamNotFoundError|StreamNotFound" + "NewJSStreamNotMatchError|StreamNotMatch" + "NewJSStreamOfflineError|StreamOffline" + "NewJSStreamReplicasNotSupportedError|StreamReplicasNotSupported" + "NewJSStreamReplicasNotUpdatableError|StreamReplicasNotUpdatable" + "NewJSStreamSealedError|StreamSealed" + "NewJSStreamSequenceNotMatchError|StreamSequenceNotMatch" + "NewJSStreamSubjectOverlapError|StreamSubjectOverlap" + "NewJSStreamTemplateNotFoundError|StreamTemplateNotFound" + "NewJSStreamTooManyRequestsError|StreamTooManyRequests" ) templated_methods=( @@ -181,6 +191,15 @@ templated_methods=( "NewJSStreamLimitsError|Exception|err|StreamLimits|{err}" "NewJSStreamMoveInProgressError|object?|msg|StreamMoveInProgress|{msg}" "NewJSStreamMsgDeleteFailedError|Exception|err|StreamMsgDeleteFailed|{err}" + "NewJSStreamOfflineReasonError|Exception|err|StreamOfflineReason|{err}" + "NewJSStreamPurgeFailedError|Exception|err|StreamPurgeFailed|{err}" + "NewJSStreamRollupFailedError|Exception|err|StreamRollupFailed|{err}" + "NewJSStreamSnapshotError|Exception|err|StreamSnapshot|{err}" + "NewJSStreamStoreFailedError|Exception|err|StreamStoreFailed|{err}" + "NewJSStreamTemplateCreateError|Exception|err|StreamTemplateCreate|{err}" + "NewJSStreamTemplateDeleteError|Exception|err|StreamTemplateDelete|{err}" + "NewJSStreamTransformInvalidDestinationError|Exception|err|StreamTransformInvalidDestination|{err}" + "NewJSStreamTransformInvalidSourceError|Exception|err|StreamTransformInvalidSource|{err}" ) templated_methods_two_args=(