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

*: Improve error handling #313

Merged
merged 1 commit into from
Feb 28, 2022
Merged

Conversation

sgotti
Copy link
Member

@sgotti sgotti commented Feb 23, 2022

  • Create an APIError that should only be used for api returned errors.
    It'll wrap an error and can have different Kinds and optional code and
    message.
  • The http handlers will use the first APIError available in the
    error chain and generate a json response body containing the code and
    the user message. The wrapped error is internal and is not sent in the
    response.
    If no api error is available in the chain a generic internal
    server error will be returned.
  • Add a RemoteError type that will be created from remote services calls
    (runservice, configstore). It's similar to the APIError but a
    different type to not propagate to the caller response and it'll not
    contain any wrapped error.
  • Gateway: when we call a remote service, by default, we'll create a
    APIError using the RemoteError Kind (omitting the code and the
    message that usually must not be propagated).
    This is done for all the remote service calls as a starting point, in
    future, if this default behavior is not the right one for a specific
    remote service call, a new api error with a different kind and/or
    augmented with the calling service error codes and user messages could
    be created.
  • datamanager: Use a dedicated ErrNotExist (and converting objectstorage
    ErrNotExist).

@sgotti sgotti force-pushed the improve_errors_handling branch 5 times, most recently from efc3874 to 9e989a5 Compare February 25, 2022 08:02
* Create an APIError that should only be used for api returned errors.
  It'll wrap an error and can have different Kinds and optional code and
  message.
* The http handlers will use the first APIError available in the
  error chain and generate a json response body containing the code and
  the user message. The wrapped error is internal and is not sent in the
  response.
  If no api error is available in the chain a generic internal
  server error will be returned.
* Add a RemoteError type that will be created from remote services calls
  (runservice, configstore). It's similar to the APIError but a
  different type to not propagate to the caller response and it'll not
  contain any wrapped error.
* Gateway: when we call a remote service, by default, we'll create a
  APIError using the RemoteError Kind (omitting the code and the
  message that usually must not be propagated).
  This is done for all the remote service calls as a starting point, in
  future, if this default behavior is not the right one for a specific
  remote service call, a new api error with a different kind and/or
  augmented with the calling service error codes and user messages could
  be created.
* datamanager: Use a dedicated ErrNotExist (and converting objectstorage
  ErrNotExist).
@sgotti sgotti force-pushed the improve_errors_handling branch from 9e989a5 to c1da3ab Compare February 25, 2022 15:11
@sgotti sgotti merged commit fa78133 into agola-io:master Feb 28, 2022
tulliobotti64 pushed a commit to tulliobotti64/agola that referenced this pull request Oct 19, 2022
tulliobotti64 pushed a commit to tulliobotti64/agola that referenced this pull request Oct 19, 2022
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.

1 participant