Skip to content

Conversation

unicornware
Copy link
Member

@unicornware unicornware commented Sep 28, 2021

Description

⚠️ BREAKING CHANGES

✨ Features

  • typescript: ExceptionData (6c3aec9)
  • type guards: Exception.isException, Exception.isExceptionJSON (ce19ccd)

♻️ Code Improvements

  • typescript!: ExceptionErrors (4fdf8c6)
  • Exception<T> extends AggregateError (0a8c8ed)
  • typescript!: ExceptionName -> ExceptionId (224636d)
  • typescript!: ExceptionStatusCode -> ExceptionCode (7bf8ef0)
  • add ExceptionJSON.data.isExceptionJSON (6878738)

🔨 Build

  • export enums as default to support esm (f7f2913)

Tests

 PASS   exceptions  packages/exceptions/src/exceptions/__tests__/base.exception.spec.ts
  unit:exceptions/Exception
    constructor
      #data
        ✓ should omit dto.data.errors and dto.data.message (1 ms)
        ✓ should use dto.data properties if dto.data is ExceptionJSON (1 ms)
      #errors
        ✓ should be array if dto.data.errors is array
        ✓ should be array if dto.data.errors is not array (1 ms)
      #message
        ✓ should not be overridden if dto.data.message is not defined
        ✓ should be overridden if dto.data.message is defined
    .findIdByCode
      ✓ should return 'INTERNAL_SERVER_ERROR' given -1 (1 ms)
      ✓ should return 'BAD_REQUEST' given 400
      ✓ should return 'UNAUTHORIZED' given 401
      ✓ should return 'PAYMENT_REQUIRED' given 402
      ✓ should return 'FORBIDDEN' given 403 (1 ms)
      ✓ should return 'NOT_FOUND' given 404
      ✓ should return 'METHOD_NOT_ALLOWED' given 405
      ✓ should return 'NOT_ACCEPTABLE' given 406
      ✓ should return 'PROXY_AUTHENTICATION_REQUIRED' given 407
      ✓ should return 'REQUEST_TIMEOUT' given 408
      ✓ should return 'CONFLICT' given 409 (5 ms)
      ✓ should return 'GONE' given 410
      ✓ should return 'LENGTH_REQUIRED' given 411
      ✓ should return 'PRECONDITION_FAILED' given 412
      ✓ should return 'PAYLOAD_TOO_LARGE' given 413 (1 ms)
      ✓ should return 'URI_TOO_LONG' given 414
      ✓ should return 'UNSUPPORTED_MEDIA_TYPE' given 415
      ✓ should return 'REQUESTED_RANGE_NOT_SATISFIABLE' given 416 (1 ms)
      ✓ should return 'EXPECTATION_FAILED' given 417
      ✓ should return 'I_AM_A_TEAPOT' given 418
      ✓ should return 'MISDIRECTED' given 421
      ✓ should return 'UNPROCESSABLE_ENTITY' given 422
      ✓ should return 'FAILED_DEPENDENCY' given 424
      ✓ should return 'TOO_MANY_REQUESTS' given 429 (1 ms)
      ✓ should return 'INTERNAL_SERVER_ERROR' given 500
      ✓ should return 'NOT_IMPLEMENTED' given 501
      ✓ should return 'BAD_GATEWAY' given 502
      ✓ should return 'SERVICE_UNAVAILABLE' given 503
      ✓ should return 'GATEWAY_TIMEOUT' given 504
      ✓ should return 'HTTP_VERSION_NOT_SUPPORTED' given 505 (1 ms)
    .formatCode
      ✓ should return 500 given -1
      ✓ should return 400 given 400
      ✓ should return 401 given 401
      ✓ should return 402 given 402
      ✓ should return 403 given 403
      ✓ should return 404 given 404 (1 ms)
      ✓ should return 405 given 405
      ✓ should return 406 given 406
      ✓ should return 407 given 407
      ✓ should return 408 given 408
      ✓ should return 409 given 409
      ✓ should return 410 given 410
      ✓ should return 411 given 411
      ✓ should return 412 given 412
      ✓ should return 413 given 413
      ✓ should return 414 given 414
      ✓ should return 415 given 415
      ✓ should return 416 given 416
      ✓ should return 417 given 417 (1 ms)
      ✓ should return 418 given 418
      ✓ should return 421 given 421
      ✓ should return 422 given 422
      ✓ should return 424 given 424
      ✓ should return 429 given 429
      ✓ should return 500 given 500
      ✓ should return 501 given 501 (1 ms)
      ✓ should return 502 given 502
      ✓ should return 503 given 503
      ✓ should return 504 given 504
      ✓ should return 505 given 505
    .fromAxiosError
      ✓ should convert error with response into Exception (2 ms)
      ✓ should convert error without response into Exception
    .fromFirebaseError
      ✓ should convert error with invalid code into Exception (1 ms)
      ✓ should convert error with valid code into Exception
    .fromNextError
      ✓ should convert error with statusCode into Exception (1 ms)
      ✓ should convert error without statusCode into Exception
    .isException
      ✓ should return false if error is not Exception
      ✓ should return true if error is Exception
    .isExceptionJSON
      ✓ should return false if ejson is not ExceptionJSON
      ✓ should return true if ejson is ExceptionJSON
    #toJSON
      ✓ should return json representation of Exception (1 ms)

Test Suites: 1 passed, 1 total
Tests:       77 passed, 77 total
Snapshots:   0 total
Time:        2.653 s, estimated 3 s
Ran all test suites.

Additional context

Linked issues

closes #5, closes P005-4

Submission checklist

  • pr title prefixed with PR: (e.g: PR: User authentication)
  • pr title describes functionality (not vague title like Update index.md)
  • pr targets branch next
  • project was run locally to verify that there are no errors
  • documentation added or updated

@unicornware unicornware added scope:typescript flag:breaking-change contains changes that require major version bump scope:exceptions exceptions type:feat new features and improvements labels Sep 28, 2021
@unicornware unicornware self-assigned this Sep 28, 2021
@unicornware unicornware marked this pull request as ready for review September 28, 2021 17:12
Copy link
Contributor

@flexdevelopment flexdevelopment left a comment

Choose a reason for hiding this comment

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

lgtm 👍🏾

@unicornware unicornware merged commit d5e4d48 into next Sep 28, 2021
@unicornware unicornware deleted the feat/P005-4-extend-aggregate-error branch September 28, 2021 17:40
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs or features. Be sure to reference this issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
flag:breaking-change contains changes that require major version bump scope:exceptions exceptions type:feat new features and improvements
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

👀 Extend AggregateError
2 participants