Skip to content

Conversation

@uschi2000
Copy link
Contributor

No description provided.

@uschi2000 uschi2000 requested a review from markelliot June 30, 2017 16:59
public static final ErrorType INVALID_ARGUMENT = createInternal(Code.INVALID_ARGUMENT, "InvalidArgument");
public static final ErrorType FAILED_PRECONDITION = createInternal(Code.FAILED_PRECONDITION, "FailedPrecondition");
public static final ErrorType CLIENT_ERROR_INVALID_ARGUMENT =
createInternal(Code.CLIENT_ERROR_INVALID_ARGUMENT, "InvalidArgument");
Copy link
Contributor

Choose a reason for hiding this comment

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

do you want to update the upper camel case names as well? (InvalidArgument -> ClientErrorInvalidArgument)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

public static final ErrorType CLIENT_ERROR_INVALID_ARGUMENT =
createInternal(Code.CLIENT_ERROR_INVALID_ARGUMENT, "InvalidArgument");
public static final ErrorType SERVER_ERROR_FAILED_PRECONDITION =
createInternal(Code.SERVER_ERROR_FAILED_PRECONDITION, "FailedPrecondition");
Copy link
Contributor

Choose a reason for hiding this comment

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

same here -- FailedPrecondition -> ServerErrorFailedPrecondition

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@pnepywoda
Copy link
Contributor

ping - really really want to release http-remoting-api with RemoteException

CLIENT_ERROR_INVALID_ARGUMENT(400),
SERVER_ERROR_FAILED_PRECONDITION(500),
INTERNAL(500),
CUSTOM(null /* unused */);

Choose a reason for hiding this comment

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

is there some way for the author of a custom error to indicate that it's a client error instead of a server error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For custom errors:

  • the error code is always CUSTOM
  • the error name is any CamelCase string (so it can include the prefix ServerError... of course)
  • the HTTP error code is either 400 (clientish) or 500 (serverish)

Copy link
Contributor Author

@uschi2000 uschi2000 Jul 6, 2017

Choose a reason for hiding this comment

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

happy with that, @markelliot ?

Choose a reason for hiding this comment

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

It seems like it'd be useful to be able to pattern match on client and server errors more explicitly

Copy link
Contributor

Choose a reason for hiding this comment

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

What do you mean? Looks like this PR suggest prefixing with "ClientError" or "ServerError" to differentiate / be able to pattern match

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I generally don't really want consumer of this to worry about HTTP codes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, plan if to have such scaffolding, but align pretty closely with the error codes. If you feel strongly that client-vs-server is the most important top-level distinction, then I'm happy to add this in a way that is easy to digest for clients.

Choose a reason for hiding this comment

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

I guess part of my flag is that if you don't want the consumer to worry about HTTP codes we probably ought to make it reasonably transparent to the producer, too, and that a producer should most likely say something like clientError(String name, int httpErrorCode) instead of custom(String name, int httpErrorCode), and we'll forcibly check that a clientError is a 400 range code, and a serverError is a 500 range code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

here's another attempt.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pnepywoda
Copy link
Contributor

ping. this is blocking releasing RemoteException which I want on a daily basis

@uschi2000
Copy link
Contributor Author

uschi2000 commented Jul 6, 2017 via email

@pnepywoda
Copy link
Contributor

@uschi2000 all good?

@pnepywoda
Copy link
Contributor

@uschi2000 ping

throw new IllegalArgumentException("Use the custom() method to construct ErrorTypes with code CUSTOM");
public static ErrorType create(Code code, String name) {
if (code == Code.CUSTOM_CLIENT || code == Code.CUSTOM_SERVER) {
throw new IllegalArgumentException("Use the client() or server() methods to construct "

Choose a reason for hiding this comment

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

So, explicitly, custom client/server errors now requires using exactly 400 and 500?

Fine with this, but slightly different than discussed. Previously had assumed we'd just keep CUSTOM as an error code, teach RemoteException to have isClientError and isServerError accessors, add these client/server methods and validate in client the numeric code was 400 range and in server the numeric code was 500 range.

Cool either way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need to whitelist the available HTTP codes since certain ones (e.g., 429, 503) will trigger under-the-cover retry/failover behavior. Simplest whitelist here is 400/500, but can always expand later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the receiving end can support three modes:

  • 4xx vs 5xx --> isClientError vs isServerError
  • switch on error code (PERMISSION_DENIED, INVALID_ARGUMENT, etc. a fixed list)
  • switch on error name (application-specific, e.g., DatasetNotFound)

@uschi2000 uschi2000 merged commit 929f8fe into develop Jul 13, 2017
@uschi2000 uschi2000 deleted the rfink/client-vs-server-error branch July 13, 2017 23:26
@jiahuijiang
Copy link
Contributor

@uschi2000 Why is FAILED_PRECONDITION changed to a server error? Isn't the standard 412?

@uschi2000
Copy link
Contributor Author

this is explicitly for a failing server-side precondition.

@jiahuijiang
Copy link
Contributor

Is there a standard for which error type to use for a client side precondition check failure? INVALID_ARGUMENT makes sense in most cases?

@uschi2000
Copy link
Contributor Author

uschi2000 commented Mar 21, 2018 via email

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.

6 participants