Put your code inside TRY...CATCH block.
Inside TRY block put your Inserts and after the END; of the TRY Block put your COMMIT command.
Inside your CATCH put your Error message and your ROLLBACK command.
See
this thread[
^]. Another useful article
here[
^].
AFAIK, you only can use Rollback inside a PROCEDURE.