Skip to content

Commit

Permalink
docs: add DefaultMappingStrategy
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexZeitler committed Nov 18, 2019
1 parent cee321c commit 2d88716
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,23 @@ import { StatusCodeErrorMapper } from 'http-problem-details-mapper'
const problem = StatusCodeErrorMapper.mapStatusCode(400)
```

Similar to the `DefaultErrorMapper` there's also a `DefaultMappingStrategy` which you can use if you have no specific requirements regarding the mapping behavior.

It can be used like this:

```js
import { MapperRegistry, DefaultMappingStrategy } from 'http-problem-details-mapper'

const strategy = new DefaultMappingStrategy(
new MapperRegistry()
.registerMapper(new NotFoundErrorMapper()))

const error = new NotFoundError({ type: 'customer', id: '123' })
const problem = strategy.map()

console.log(problem)
```

## Running the tests

```
Expand Down

0 comments on commit 2d88716

Please sign in to comment.