Skip to content
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

(dsl): Support GetById request #5

Merged
merged 13 commits into from
Nov 28, 2022
Merged

(dsl): Support GetById request #5

merged 13 commits into from
Nov 28, 2022

Conversation

drmarjanovic
Copy link
Member

No description provided.

routing: Option[Routing] = None
) extends ElasticRequest[Option[Document]]

sealed abstract class DocumentGettingError
Copy link
Member Author

Choose a reason for hiding this comment

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

I would probably extract errors to a separate file. Also, I would name it more generally. Not just DocumentGettingError. Either ElasticError or something like that. @arnoldlacko, any thoughts?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would avoid having one enum for all errors, because it reduces the benefits of typed errors. For example put, which will not be able to fail with DocumentNotFound I believe should have an error type that does not have this error as a possibility. If we only have ElasticError, a user calling a put will have to deal with DocumentNotFound or make assumptions that are not enforced by the type system.
I think we could find better names for the error groups for sure, but I wouldn't merge them into one.

Copy link
Collaborator

@arnoldlacko arnoldlacko Nov 24, 2022

Choose a reason for hiding this comment

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

Perhaps for now we can expect to have 3 abstract error types: GetError, PutError, QueryError?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Regarding the extraction into a separate file, I think that makes sense.


case object DocumentNotFound extends DocumentGettingError

case class JsonDecoderError(errorMsg: String) extends DocumentGettingError
Copy link
Member Author

Choose a reason for hiding this comment

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

  • I prefer final case class.
  • Can you use message or reason instead?


object ElasticError {

sealed abstract class DocumentGettingError
Copy link
Member Author

Choose a reason for hiding this comment

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

What do you think about having only sealed trait ElasticError at the moment?

final case object DocumentNotFound extends ElasticError

final case class DecoderError(reason: String) extends ElasticError

We should consider this because we don't have a lot of errors, and maybe it's too early to introduce several layers of error types.


final case object DocumentNotFound extends DocumentGettingError

final case class JsonDecoderError(message: String) extends DocumentGettingError
Copy link
Member Author

Choose a reason for hiding this comment

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

I would omit Json prefix here, and possibly change message to reason(s).

@drmarjanovic drmarjanovic merged commit 5f40fda into main Nov 28, 2022
@drmarjanovic drmarjanovic deleted the dsl-get-by-id-request branch November 28, 2022 08:51
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.

4 participants