Turn audio into a shareable video. forked from nypublicradio/audiogram

error.js 625B

12345678910111213141516171819202122232425262728293031
  1. var serverSettings = require("../settings/");
  2. module.exports = function(err, req, res, next) {
  3. if (!err) {
  4. // This should never happen
  5. return next ? next() : null;
  6. }
  7. res.status(500);
  8. if (err.code === "LIMIT_FILE_SIZE") {
  9. res.send("Sorry, uploads are limited to " + prettySize(serverSettings.maxUploadSize) + ". Try clipping your file or converting it to an MP3.");
  10. } else {
  11. res.send("Unknown error.");
  12. throw err;
  13. }
  14. };
  15. function prettySize(size) {
  16. var mb = size / 1000000,
  17. rounded = mb >= 1 ? Math.floor(10 * mb) / 10 : Math.floor(100 * mb) / 100;
  18. return rounded + " MB";
  19. }