Better support for different types of errors in javascript upload code