KevinMidboe / seasonedShows

seasoned api 🌶 | Season your media library with the shows and movies that you and your friends want
MIT License
2 stars 0 forks source link

Write middleware for handling tmdb errors #116

Open KevinMidboe opened 5 years ago

KevinMidboe commented 5 years ago

Do like started on movieInfo and showInfo. There we check the status codes right after our requests to themoviedb api.

Improvements:

Example:

.catch(error => {
  if (error.status === 401) {
    throw new Error('Unathorized tmdb request, please check api key.')
  } else  if (error.status === 404) {
    throw new Error(`Could not find a movie with id: ${identifier}`)
  }

  throw new Error('Unexpected error has occured:', error.message)
})
KevinMidboe commented 5 years ago

Save for database errors