Add exception throwing to loadLibrary

Closes #112