Add lineprof to handle exceptions in sample

Small wrapper over the `lineprof` function to raises a `RuntimeError` with an error message indicating that the sampled code threw an exception.