Skip to content

Commit

Permalink
Removed try catch with api. It's useless.
Browse files Browse the repository at this point in the history
  • Loading branch information
simplyzee committed Jul 3, 2016
1 parent 4e2073a commit dee8a1d
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 76 deletions.
29 changes: 28 additions & 1 deletion .snyk
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,31 @@ patch:
'npm:uglify-js:20151024':
- jade > transformers > uglify-js:
patched: '2016-05-04T08:44:52.644Z'
version: v1
'npm:minimatch:20160620':
- forever-monitor > minimatch:
patched: '2016-07-03T13:48:08.042Z'
- forever-monitor > chokidar > fsevents > node-pre-gyp > tar > fstream > rimraf > glob > minimatch:
patched: '2016-07-03T13:48:08.042Z'
- forever-monitor > chokidar > fsevents > node-pre-gyp > tar-pack > tar > fstream > rimraf > glob > minimatch:
patched: '2016-07-03T13:48:08.042Z'
- forever-monitor > chokidar > fsevents > node-pre-gyp > tar-pack > fstream > rimraf > glob > minimatch:
patched: '2016-07-03T13:48:08.042Z'
- forever-monitor > chokidar > fsevents > node-pre-gyp > tar-pack > fstream-ignore > fstream > rimraf > glob > minimatch:
patched: '2016-07-03T13:48:08.042Z'
- forever-monitor > chokidar > fsevents > node-pre-gyp > tar-pack > rimraf > glob > minimatch:
patched: '2016-07-03T13:48:08.042Z'
- forever-monitor > chokidar > fsevents > node-pre-gyp > rimraf > glob > minimatch:
patched: '2016-07-03T13:48:08.042Z'
- istanbul > fileset > minimatch:
patched: '2016-07-03T13:48:08.042Z'
- forever-monitor > chokidar > fsevents > node-pre-gyp > tar-pack > fstream-ignore > minimatch:
patched: '2016-07-03T13:48:08.042Z'
version: v1.5.0
ignore:
'npm:minimatch:20160620':
- mocha > glob > minimatch:
reason: no update as of yet from package
expires: '2016-08-02T13:49:03.597Z'
- snyk > recursive-readdir > minimatch:
reason: no update from package module
expires: '2016-08-02T13:49:03.598Z'
138 changes: 66 additions & 72 deletions helpers/moviedb-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ function getMoviesFromSearch(movieName, req) {
if(!movieName)
reject();

try {
tmdb.searchMovie({query: movieName}, function(error, response) {
resolve(response);
});
} catch (err) {
log.error({err: err}, 'Problem querying the search endpoint');
reject(new Error('Problem querying the search endpoint'));
}
tmdb.searchMovie({query: movieName}, function(error, response) {
if(error) {
log.error({error: error}, 'Problem querying the search endpoint');
reject(new Error('Problem querying the search endpoint'));
}

resolve(response);
});
});
}

Expand All @@ -26,14 +26,14 @@ function getMovieById(movieId, req) {
if(!movieId)
reject();

try {
tmdb.movieInfo({id: movieId}, function(error, response) {
resolve(response);
});
} catch (err) {
log.error({err: err}, 'Problem getting movie information by id');
reject(new Error('Problem getting movie information by id'));
}
tmdb.movieInfo({id: movieId}, function(error, response) {
if(error) {
log.error({error: error}, 'Problem getting movie information by id');
reject(new Error('Problem getting movie information by id'));
}

resolve(response);
});
});
}

Expand All @@ -42,14 +42,14 @@ function getMovieCreditsById(movieId, req) {
if(!movieId)
reject();

try {
tmdb.movieCredits({id: movieId}, function(error, response) {
resolve(response);
});
} catch (err) {
log.error({err: err}, 'Problem getting movie credits by id');
reject(new Error('Problem getting movie credits by id'));
}
tmdb.movieCredits({id: movieId}, function(error, response) {
if(error) {
log.error({error: error}, 'Problem getting movie credits by id');
reject(new Error('Problem getting movie credits by id'));
}

resolve(response);
});
});
}

Expand All @@ -58,14 +58,13 @@ function getMovieImagesById(movieId, req) {
if(!movieId)
reject();

try {
tmdb.movieImages({id: movieId}, function(error, response) {
resolve(response);
});
} catch (err) {
log.error({err: err}, 'Problem getting movie images by id');
reject(new Error('Problem getting movie images by id'));
}
tmdb.movieImages({id: movieId}, function(error, response) {
if(error) {
log.error({error: error}, 'Problem getting movie images by id');
reject(new Error('Problem getting movie images by id'));
}
resolve(response);
});
});
}

Expand All @@ -74,14 +73,13 @@ function getMovieVideosById(movieId, req) {
if(!movieId)
reject();

try {
tmdb.movieVideos({id: movieId}, function(error, response) {
resolve(response);
});
} catch (err) {
log.error({err: err}, 'Problem getting movie videos by id');
reject(new Error('Problem getting movie videos by id'));
}
tmdb.movieVideos({id: movieId}, function(error, response) {
if(error) {
log.error({error: error}, 'Problem getting movie videos by id');
reject(new Error('Problem getting movie videos by id'));
}
resolve(response);
});
});
}

Expand All @@ -90,14 +88,13 @@ function getMovieTrailerById(movieId, req) {
if(!movieId)
reject();

try {
tmdb.movieTrailers({id: movieId}, function(error, response) {
resolve(response);
});
} catch (err) {
log.error({err: err}, 'Problem getting movie trailers by id');
reject(new Error('Problem getting movie trailers by id'));
}
tmdb.movieTrailers({id: movieId}, function(error, response) {
if(error) {
log.error({error: error}, 'Problem getting movie trailers by id');
reject(new Error('Problem getting movie trailers by id'));
}
resolve(response);
});
});
}

Expand All @@ -106,14 +103,13 @@ function getMovieKeywordsById(movieId, req) {
if(!movieId)
reject();

try {
tmdb.movieKeywords({id: movieId}, function(error, response) {
resolve(response);
});
} catch (err) {
log.error({err: err}, 'Problem getting movie keywords by id');
reject(new Error('Problem getting movie keywords by id'));
}
tmdb.movieKeywords({id: movieId}, function(error, response) {
if(error) {
log.error({error: error}, 'Problem getting movie keywords by id');
reject(new Error('Problem getting movie keywords by id'));
}
resolve(response);
});
});
}

Expand All @@ -122,28 +118,26 @@ function getSimilarMoviesById(movieId, req) {
if(!movieId)
reject();

try {
tmdb.movieSimilar({id: movieId}, function(error, response) {
resolve(response);
});
} catch (err) {
log.error({err: err}, 'Problem getting similar movies by id');
reject(new Error('Problem getting similar movies by id'));
}
tmdb.movieSimilar({id: movieId}, function(error, response) {
if(error) {
log.error({error: error}, 'Problem getting similar movies by id');
reject(new Error('Problem getting similar movies by id'));
}
resolve(response);
});
});
}

function getLatestMovies(req) {
return new Promise((resolve, reject) => {

try {
tmdb.miscNowPlayingMovies({}, function(error, response) {
resolve(response);
});
} catch (err) {
log.error({err: err}, 'Problem getting latest movies');
reject(new Error('Problem getting latest movies'));
}
tmdb.miscNowPlayingMovies({}, function(error, response) {
if(error) {
log.error({error: error}, 'Problem getting latest movies');
reject(new Error('Problem getting latest movies'));
}
resolve(response);
});
});
}

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
},
"dependencies": {
"body-parser": "~1.13.2",
"bunyan": "^1.6.0",
"bunyan": "^1.8.1",
"cookie-parser": "~1.3.5",
"debug": "~2.2.0",
"express": "^4.12.4",
"express": "^4.14.0",
"forever-monitor": "^1.7.0",
"helmet": "^1.1.0",
"istanbul": "^0.4.2",
"istanbul": "^0.4.3",
"mocha": "^2.4.5",
"morgan": "^1.6.1",
"moviedb": "^0.2.2",
Expand Down

0 comments on commit dee8a1d

Please sign in to comment.