Fix: Tests lint and src folder #138
@@ -38,17 +38,17 @@ class TMDBNotReachableError extends Error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const tmdbErrorResponse = (error, type = null) => {
|
const tmdbErrorResponse = (error, type = null) => {
|
||||||
if (error.status === 404) {
|
if (error?.status === 404) {
|
||||||
const message = error.response.body.status_message;
|
const message = error?.response?.body?.status_message;
|
||||||
|
|
||||||
throw new TMDBNotFoundError(`${message.slice(0, -1)} in tmdb.`);
|
throw new TMDBNotFoundError(`${message.slice(0, -1)} in tmdb.`);
|
||||||
} else if (error.status === 401) {
|
} else if (error?.status === 401) {
|
||||||
throw new TMDBUnauthorizedError(error?.response?.body?.status_message);
|
throw new TMDBUnauthorizedError(error?.response?.body?.status_message);
|
||||||
} else if (error?.code === "ENOTFOUND") {
|
} else if (error?.code === "ENOTFOUND") {
|
||||||
throw new TMDBNotReachableError();
|
throw new TMDBNotReachableError();
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new TMDBUnexpectedError(type, error);
|
throw new TMDBUnexpectedError(type, error.message);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ async function movieInfoController(req, res) {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
return res.status(error?.statusCode || 500).send({
|
return res.status(error?.statusCode || 500).send({
|
||||||
success: false,
|
success: false,
|
||||||
|
errorMessage: error?.errorMessage,
|
||||||
message:
|
message:
|
||||||
error?.message ||
|
error?.message ||
|
||||||
`An unexpected error occured while requesting info for with id: ${movieId}`
|
`An unexpected error occured while requesting info for with id: ${movieId}`
|
||||||
|
|||||||
Reference in New Issue
Block a user