Capture last command In bash

For whatever reason you may want to save the last command you wrote. Heres a way to do so. this command allows you to only capture commands that through an error