[
https://issues.apache.org/jira/browse/IGNITE-19864?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Vyacheslav Koptilin updated IGNITE-19864:
-----------------------------------------
Ignite Flags: (was: Docs Required,Release Notes Required)
> Introduce TraceableException interface
> --------------------------------------
>
> Key: IGNITE-19864
> URL: https://issues.apache.org/jira/browse/IGNITE-19864
> Project: Ignite
> Issue Type: Improvement
> Reporter: Vyacheslav Koptilin
> Assignee: Vyacheslav Koptilin
> Priority: Major
> Labels: ignite-3
> Fix For: 3.0.0-beta2
>
> Time Spent: 20m
> Remaining Estimate: 0h
>
> It seems useful to introduce TraceableException, which should be a base
> interface for all internal and public exception classes, that provides a
> simple way to get a trace identifier and error code.
> {code:java}
> public interface TraceableException {
> /**
> * Returns a unique identifier of the exception.
> *
> * @return Unique identifier of the exception.
> */
> UUID traceId();
> /**
> * Returns a full error code that includes the error's group and code,
> which uniquely identifies the problem within the group. This is a
> * combination of two most-significant bytes for the error group and two
> least-significant bytes for the error code.
> *
> * @return Full error code.
> */
> public int code();
> /**
> * Returns an error group.
> *
> * @see #code()
> * @return Error group.
> */
> public int groupCode();
> /**
> * Returns an error code that uniquely identifies the problem within a
> group.
> *
> * @see #code()
> * @see #groupCode()
> * @return Error code.
> */
> public int errorCode();
> }
> {code}
> It will allow us to simplify a bit the code as follows:
> {code:java}
> public static @Nullable UUID extractTraceIdFrom(Throwable t) {
> if (t instanceof IgniteException) {
> return ((IgniteException) t).traceId();
> } else if (t instanceof IgniteCheckedException) {
> return ((IgniteCheckedException) t).traceId();
> } else if (t instanceof IgniteInternalException) {
> return ((IgniteInternalException) t).traceId();
> } else if (t instanceof IgniteInternalCheckedException) {
> return ((IgniteInternalCheckedException) t).traceId();
> }
> return null;
> }
> This boilerplate code can be changed to:
> public static @Nullable UUID extractTraceIdFrom(Throwable t) {
> if (t instanceof TraceableException) {
> return ((TraceableException) t).traceId();
> }
> return null;
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)