refactor bailey.js: extract error handling to main(), add onError and onFile for parseFiles