<commit_before># Catching Errors Thrown by Rejected Promises

## The Principle

Redux promise middleware dispatches an action for a rejected promise, but does not catch the error thrown. **This is an expected behavior.** Because the error is not caught, you will (in most cases) get an "uncaught" warning in the developer console. Again, this is an expected behavior.

By principle, it's your applications's responsibility to catch the error thrown by the rejected promise. It's not the responsibility of the middleware.

## How to Catch Promises

However, you probably want to catch the error. Here's some suggested approaches/solutions to this.

1. Catch/handle the error "globally" in a error handling middleware
2. Catch/handle the error "locally" at the action creator

## Catching Errors Locally

Generally, it'll make sense to use local error handling to directly control the "side effect(s)" of an error.
<commit_msg>Update rejected-promises.md (#247)<commit_after># Catching Errors Thrown by Rejected Promises

## The Principle

Redux promise middleware dispatches an action for a rejected promise, but does not catch the error thrown. **This is an expected behavior.** Because the error is not caught, you will (in most cases) get an "uncaught" warning in the developer console. Again, this is an expected behavior.

By principle, it's your application's responsibility to catch the error thrown by the rejected promise. It's not the responsibility of the middleware.

## How to Catch Promises

However, you probably want to catch the error. Here's some suggested approaches/solutions to this.

1. Catch/handle the error "globally" in error handling middleware
2. Catch/handle the error "locally" at the action creator

## Catching Errors Locally

Generally, it'll make sense to use local error handling to directly control the "side effect(s)" of an error.

{'fraction_non_alphanumeric': 0.05728051391862955, 'fraction_numerical': 0.003747323340471092, 'mean_word_length': 4.733128834355829, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6517769', 'n_tokens_mistral': 490, 'n_tokens_neox': 463, 'n_words': 273}