How to track the workflow error and log into new table?

Is there any possibility to track the workflow error/timeout is happen then need to track into database table for reference?