> i have written function in which while executing it may throw error.
> if the error thrown i want rollback the transaction if not i want commit.
BEGIN;
SELECT you_function(args);
...
many sql commands;
...
COMMIT;
that's all
if your function raises an error
whole transaction will be aborted when the COMMIT is called.