errors.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. var util = require('util');
  2. // Error list with code and message
  3. var list = {
  4. 'empty_input_filepath' : { 'code' : 100, 'msg' : 'The input file path can not be empty' }
  5. , 'input_filepath_must_be_string' : { 'code' : 101, 'msg' : 'The input file path must be a string' }
  6. , 'invalid_option_name' : { 'code' : 102, 'msg' : 'The option "%s" is invalid. Check the list of available options' }
  7. , 'fileinput_not_exist' : { 'code' : 103, 'msg' : 'The input file does not exist' }
  8. , 'format_not_supported' : { 'code' : 104, 'msg' : 'The format "$s" is not supported by the version of ffmpeg' }
  9. , 'audio_channel_is_invalid' : { 'code' : 105, 'msg' : 'The audio channel "$s" is not valid' }
  10. , 'mkdir' : { 'code' : 106, 'msg' : 'Error occurred during creation folder: $s' }
  11. , 'extract_frame_invalid_everyN_options' : { 'code' : 107, 'msg' : 'You can specify only one option between everyNFrames and everyNSeconds' }
  12. , 'invalid_watermark' : { 'code' : 108, 'msg' : 'The watermark "%s" does not exists' }
  13. , 'invalid_watermark_position' : { 'code' : 109, 'msg' : 'Invalid watermark position "%s"' }
  14. , 'size_format' : { 'code' : 110, 'msg' : 'The format "%s" not supported by the function "setSize"' }
  15. , 'resolution_square_not_defined' : { 'code' : 111, 'msg' : 'The resolution for pixel aspect ratio is not defined' }
  16. , 'command_already_exists' : { 'code' : 112, 'msg' : 'The command "%s" already exists' }
  17. , 'codec_not_supported' : { 'code' : 113, 'msg' : 'The codec "$s" is not supported by the version of ffmpeg' }
  18. }
  19. /**
  20. * Return the error by the codename
  21. */
  22. var renderError = function (codeName) {
  23. // Get the error object by the codename
  24. var params = [list[codeName].msg];
  25. // Get the possible arguments
  26. if (arguments.length > 1)
  27. params = params.concat(Array.prototype.slice.call(arguments, 1));
  28. // Call the function for replace the letter '%s' with the found arguments
  29. return { 'code' : list[codeName].code, 'msg' : util.format.apply(this, params) };
  30. }
  31. module.exports.list = list;
  32. module.exports.renderError = renderError;