Log the stack trace when a LoadingQueue task throws an error

Fixes #658.