-
Notifications
You must be signed in to change notification settings - Fork 0
Restore ExceptionFactory
#281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d1b154a
bc0b218
d4533ea
9836383
1156165
6d9a5ff
4e01e27
98c8003
e896676
2c9d70f
23c6ca0
348e14a
36d35ed
a7b0090
6a72da7
64ef837
6a7d65d
0330f4e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
| +1 −1 | external/build.gradle.kts | |
| +1 −1 | first-model/build.gradle.kts |
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,151 @@ | ||||||||||||||
| /* | ||||||||||||||
| * Copyright 2025, TeamDev. All rights reserved. | ||||||||||||||
| * | ||||||||||||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||||||||||||||
| * you may not use this file except in compliance with the License. | ||||||||||||||
| * You may obtain a copy of the License at | ||||||||||||||
| * | ||||||||||||||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||||||||||||||
| * | ||||||||||||||
| * Redistribution and use in source and/or binary forms, with or without | ||||||||||||||
| * modification, must retain the above copyright notice and the following | ||||||||||||||
| * disclaimer. | ||||||||||||||
| * | ||||||||||||||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||||||||||||||
| * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||||||||||||||
| * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||||||||||||||
| * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||||||||||||||
| * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||||||||||||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||||||||||||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||||||||||||||
| * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||||||||||||||
| * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||||||||||||||
| * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||||||||||||||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||||||||||||
| */ | ||||||||||||||
|
|
||||||||||||||
| package io.spine.validation; | ||||||||||||||
|
|
||||||||||||||
| import com.google.common.collect.ImmutableList; | ||||||||||||||
| import com.google.protobuf.Message; | ||||||||||||||
| import com.google.protobuf.ProtocolMessageEnum; | ||||||||||||||
| import com.google.protobuf.Value; | ||||||||||||||
| import io.spine.annotation.Internal; | ||||||||||||||
| import io.spine.base.Error; | ||||||||||||||
| import io.spine.protobuf.AnyPacker; | ||||||||||||||
| import io.spine.type.MessageClass; | ||||||||||||||
|
|
||||||||||||||
| import java.util.Map; | ||||||||||||||
|
|
||||||||||||||
| import static java.lang.String.format; | ||||||||||||||
|
|
||||||||||||||
| /** | ||||||||||||||
| * A helper class for building exceptions used to report invalid {@code Message}s, | ||||||||||||||
| * which have fields that violate validation constraint(s). | ||||||||||||||
| * | ||||||||||||||
| * @param <E> | ||||||||||||||
| * the type of {@code Exception} to build | ||||||||||||||
| * @param <M> | ||||||||||||||
| * the type of the {@code Message}, typically it would be a grouping interface such as | ||||||||||||||
| * {@link io.spine.base.EventMessage} or {@link io.spine.base.CommandMessage} | ||||||||||||||
| * @param <C> | ||||||||||||||
| * the type of the {@linkplain io.spine.type.MessageClass} of {@code |M|} | ||||||||||||||
| * @param <R> | ||||||||||||||
| * the type of error code to use for error reporting; must be a Protobuf enum value | ||||||||||||||
| */ | ||||||||||||||
| @Internal | ||||||||||||||
| public abstract class ExceptionFactory<E extends Exception, | ||||||||||||||
| M extends Message, | ||||||||||||||
| C extends MessageClass<?>, | ||||||||||||||
|
alexander-yevsyukov marked this conversation as resolved.
|
||||||||||||||
| R extends ProtocolMessageEnum> { | ||||||||||||||
|
|
||||||||||||||
| private final ImmutableList<ConstraintViolation> constraintViolations; | ||||||||||||||
| private final M message; | ||||||||||||||
|
|
||||||||||||||
| /** | ||||||||||||||
| * Creates an {@code ExceptionFactory} instance for a given message and | ||||||||||||||
| * constraint violations. | ||||||||||||||
| * | ||||||||||||||
| * @param message | ||||||||||||||
| * an invalid event message | ||||||||||||||
| * @param violations | ||||||||||||||
| * constraint violations for the event message | ||||||||||||||
|
Comment on lines
+70
to
+72
|
||||||||||||||
| * an invalid event message | |
| * @param violations | |
| * constraint violations for the event message | |
| * an invalid message | |
| * @param violations | |
| * constraint violations for the message |
Copilot
AI
Mar 25, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The phrase “create an instance of exception basing on…” is grammatically incorrect and makes the Javadoc harder to read. Please reword it (e.g. “based on”).
| * Defines the way to create an instance of exception basing on the source {@code Message}, | |
| * Defines how to create an exception instance based on the source {@code Message}, |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Javadoc for type parameter
Ccontains{@code |M|}, which looks like a formatting artifact and will render incorrectly. Replace it with the intended reference (e.g.{@code M}) so the generated docs are correct.