Skip to content

Conversation

@amorton
Copy link
Contributor

@amorton amorton commented Jan 14, 2026

What this PR does:

Which issue(s) this PR fixes:
Fixes #

Checklist

  • Changes manually tested
  • Automated Tests added/updated
  • Documentation added/updated
  • CLA Signed: DataStax CLA

@amorton amorton requested a review from a team as a code owner January 14, 2026 20:31
var builder = CommandErrorV2.builder();

if (debugEnabled) {
builder.errorClass(jsonApiException.getClass().getSimpleName());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: could move logic to builder, which would take Throwable, access debugEnabled on its own, add e.getClass().getSimpleName() if debug enabled.

.build();
}

public CommandErrorV2 create(APIException apiException) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems redundant as we already have:

public CommandErrorV2 create(Throwable throwable);

which calls the main

public CommandErrorV2 create(Throwable throwable, List<? extends DocRowIdentifer> documentIds)

which calls Yet Another create() method...


public String getTitle() {
return title;
// XXX TO COMMENT
Copy link
Contributor

@tatu-at-datastax tatu-at-datastax Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the comment? :)

Esp. since I am not quite sure what the logic is wrt "identity" in this case: was about to suggest implementation on top of equals() but that's not what is being done here.

this.documentIds =
documentIds == null
? Collections.emptyList()
: documentIds.stream().map(d -> (DocRowIdentifer) d).toList();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this just for creating a copy of List? I guess it is to "convert" from List<? extends DocRowIdentifer> to List< DocRowIdentifer>.

Copy link
Contributor

@tatu-at-datastax tatu-at-datastax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM: a few nits, typos, questions.

// another builder, because if we add a warning we want to use the V2 error object
// but may not be returning V2 errors in the result
private final APIExceptionCommandErrorBuilder apiWarningToError;
// amorton - we could probably use the same factory for errors and warning, keeping seperate
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: seperate -> separate

}

/**
* Enables debug for the duration of a try-with-resources block.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed?

return commandResult.toRestResponse();
}
}
// public class GenericExceptionMapper {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete the file

return builder.build();
}
}
// public record ThrowableCommandResultSupplier(Throwable t) implements Supplier<CommandResult> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete

*
* <p>Changed the role to ONLY be remaping Java exception to exception. Previously it would also
* build the Command error (CommandResult.Error) that is returned to the client. Made the change to
* try simplifying as I work to remove this class completly.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: completly -> completely

import org.jboss.resteasy.reactive.server.ServerExceptionMapper;

/** Tries to omit the `WebApplicationException` and just report the cause. */
/** Tries to omit the `WebApplicationException` and just report the cause. <p/ */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: remove <p/

// Cannot get a session from the sessionCacheSupplier in the constructor because
// it will create a circular call. So need to wait until now to create the QueryExecutor
// this is OK, only happens when the table is not in the cache
// HACK - fix before merge
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm?

map ->
map.put(
"errorMessage",
"Collection creation failure (unable to create table)."))));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: usually trailing period part of template, not substitution part.

// is error
tags.add(ExceptionMetrics.TAG_ERROR_TRUE);
// let error bubble, there must be a first error
// XXX AARON TODO - old code use a single error, can we use more than one tag value ? Cannot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: old code use -> old code uses

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants