Throw proper errors instead of strings.

Also don't rely on prototype extensions for formatting errors