print more descriptive error messages when source is undefined (as in #979)

This commit is contained in:
Federico Soave 2018-01-02 15:10:01 +01:00
parent f9e817d9fb
commit 1ec0bf387f

View File

@ -1144,8 +1144,13 @@ function merge(obj) {
*/ */
function marked(src, opt, callback) { function marked(src, opt, callback) {
// return null in case of non valid input // throw error in case of non string input
if (typeof src != 'string') return null; if (typeof src == 'undefined' || src === null)
throw new Error('marked(): input parameter is undefined or null');
if (typeof src != 'string')
throw new Error('marked(): input parameter is of type ' +
Object.prototype.toString.call(src) + ', string expected');
if (callback || typeof opt === 'function') { if (callback || typeof opt === 'function') {
if (!callback) { if (!callback) {