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

Refactoring backend codebase to use central error handling and logging #152

Merged
merged 8 commits into from
Dec 25, 2022

Commits on Dec 21, 2022

  1. feat: Add central error handler

    Added:
    - Added Midleware to capture and handle all errors
        - will catch error from `throw ...` and `next(...)`
    - Added RequestError base error class to build consistent error objects
    - Added common errors like `UnauthorizedRequestError`, `BadRequestError`
    - Added consistent Logging solution using `winston`
        - Supports Loki Transporter using `winston-loki`
    - Outputing Legal disclaimer to console when `TELEMETRY_ENABLED=true`
    
    Changed:
    - Changed console.log to getLogger() favor of using consistent logging
    Zamion101 committed Dec 21, 2022
    Configuration menu
    Copy the full SHA
    bd9041a View commit details
    Browse the repository at this point in the history

Commits on Dec 22, 2022

  1. refactor: Refactored middlewares to use RequestError

    Refactored middlewares to use RequestError rather than using
    `try {...}catch (err){...}`. With this change it's possible to manage
    all error details within one place.
    
    Added:
    - Added Sentry.captureException to Error Handler
    Zamion101 committed Dec 22, 2022
    Configuration menu
    Copy the full SHA
    6f5d7a8 View commit details
    Browse the repository at this point in the history
  2. fix: Wrong error handler middleware position

    Error handler is a middleware that captures errors from throw and
    next(...), so in order to be able to handle it needs to come after
    all of the routing and other middlewares. Previously it was before
    routuing logic and wasn't working, now it works as intended.
    
    Also added check for LogLevel to Sentry for not sending false-positive
    errors like `BadRequestError`, `UnauthorizedRequestError` and etc.
    Zamion101 committed Dec 22, 2022
    Configuration menu
    Copy the full SHA
    843757f View commit details
    Browse the repository at this point in the history

Commits on Dec 24, 2022

  1. refactor: Prefer use of RequestError and next() function on middlewares

    Added:
    - New error types such as `IntegrationNotFoundError`,
      `WorkspaceNotFoundError`, `AccountNotFoundError' and more.
    
    Refactored:
    - Refactored most of the middlewares and very little number of helper
      functions to use RequestError
    - Deleted unused imports
    
    Changed:
    - Some of the error types in middlewares changed to more related error
      types.
    - Environment variable of 'VERBOSE_ERROR_OUTPUT' changed to more
      reliable validation method in `config/index.ts` as per @dangtony98
      requested.
    Zamion101 committed Dec 24, 2022
    Configuration menu
    Copy the full SHA
    28818db View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    6216f70 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    22d6aa8 View commit details
    Browse the repository at this point in the history
  4. feat: Patch Router#handle to catch Promise Rejection

    In order to catch Promise rejections inside and outside of middlewares
    as well as in route logic we need to patch `Router#handle` and add
    .catch() to the function. With that addition it is possible to
    catch rejections and handle inside `requestErrorHandler` middleware.
    Zamion101 committed Dec 24, 2022
    Configuration menu
    Copy the full SHA
    d72e113 View commit details
    Browse the repository at this point in the history

Commits on Dec 25, 2022

  1. Configuration menu
    Copy the full SHA
    a12ae35 View commit details
    Browse the repository at this point in the history