1.1.41 • Published 4 years ago

@mon-medic/common v1.1.41

Weekly downloads
908
License
ISC
Repository
-
Last release
4 years ago

commons-service

commons-service

HttpExceptionFilter

to Catch every unhandled exception (regardless of the exception type) and make the response as

{
    errors: [
        feilds: string[],
        messages: string,
        code: string
    ]
}

this Filter handle three types of errors

  • validation errors from the dto level
  • unexpected error
  • validation in the business logic but at this level, you want to handle the structure of the error manually like that
throw new ConflictException({
            fields: ['feild'],
            code: 'CONFLICTS',
            message: 'your message',
          });

How to use it on the nestjs project

  • in the main.ts file, import the module
import { HttpExceptionFilter } from '@mon-medic/common';
  • in the bootstrap function add this line
  app.useGlobalFilters(new HttpExceptionFilter());
1.1.38

4 years ago

1.1.39

4 years ago

1.1.41

4 years ago

1.1.40

4 years ago

1.1.37

4 years ago

1.1.36

4 years ago

1.1.35

4 years ago

1.1.33

4 years ago

1.1.32

4 years ago

1.1.29

4 years ago

1.1.28

4 years ago

1.1.30

4 years ago

1.1.31

4 years ago

1.1.27

4 years ago

1.1.26

4 years ago

1.1.25

4 years ago

1.1.24

4 years ago

1.1.23

4 years ago

1.1.19

4 years ago

1.1.18

4 years ago

1.1.22

4 years ago

1.1.21

4 years ago

1.1.20

4 years ago

1.1.16

4 years ago

1.1.17

4 years ago

1.1.15

4 years ago

1.1.14

4 years ago

1.1.13

4 years ago

1.1.12

4 years ago

1.1.11

4 years ago

1.1.9

4 years ago

1.1.8

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.10

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.1

4 years ago

1.1.2

4 years ago

1.0.24

4 years ago

1.0.22

4 years ago

1.0.23

4 years ago

1.0.21

4 years ago

1.0.20

4 years ago

1.0.19

4 years ago

1.0.18

4 years ago

1.0.17

4 years ago

1.0.16

4 years ago

1.0.15

4 years ago

1.0.14

5 years ago

1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago