1.1.41 • Published 3 years ago

@mon-medic/common v1.1.41

Weekly downloads
908
License
ISC
Repository
-
Last release
3 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

3 years ago

1.1.39

3 years ago

1.1.41

3 years ago

1.1.40

3 years ago

1.1.37

3 years ago

1.1.36

3 years ago

1.1.35

3 years ago

1.1.33

3 years ago

1.1.32

3 years ago

1.1.29

3 years ago

1.1.28

3 years ago

1.1.30

3 years ago

1.1.31

3 years ago

1.1.27

3 years ago

1.1.26

3 years ago

1.1.25

3 years ago

1.1.24

3 years ago

1.1.23

3 years ago

1.1.19

3 years ago

1.1.18

3 years ago

1.1.22

3 years ago

1.1.21

3 years ago

1.1.20

3 years ago

1.1.16

3 years ago

1.1.17

3 years ago

1.1.15

3 years ago

1.1.14

3 years ago

1.1.13

3 years ago

1.1.12

3 years ago

1.1.11

3 years ago

1.1.9

3 years ago

1.1.8

3 years ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.10

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.1

3 years ago

1.1.2

3 years ago

1.0.24

3 years ago

1.0.22

3 years ago

1.0.23

3 years ago

1.0.21

3 years ago

1.0.20

3 years ago

1.0.19

3 years ago

1.0.18

3 years ago

1.0.17

3 years ago

1.0.16

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago