intercept parse errors with options.onerror

pull/199/head
Rich Harris 8 years ago
parent a4a67ff98f
commit a9262f45ea

@ -16,13 +16,25 @@ function normalizeOptions ( options ) {
} else { } else {
console.warn( warning.message ); // eslint-disable-line no-console console.warn( warning.message ); // eslint-disable-line no-console
} }
},
onerror: error => {
throw error;
} }
}, options ); }, options );
} }
export function compile ( source, _options ) { export function compile ( source, _options ) {
const options = normalizeOptions( _options ); const options = normalizeOptions( _options );
const parsed = parse( source, options );
let parsed;
try {
parsed = parse( source );
} catch ( err ) {
options.onerror( err );
return;
}
const { names } = validate( parsed, source, options ); const { names } = validate( parsed, source, options );

Loading…
Cancel
Save