Use error object for exceptions

When throwing an exception just by string, then `stack` is not available.