Owwwww (tmi no picture)

I'm sorry if this is super gross...so I get up to go to the bathroom because I can't get comfortable and I feel like I need to go #2...I get in there and get situated and nothing...just super bad gas pains that couldn't be alleviated by any of the methods I've used before...and then finally after sitting is the worst pain and feeling as though I may puke I finally do what I came in the bathroom to do and I can't even begin to understand why that just happened...I've had problems going a few times but nothing like that...has anyone else dealt with this problem before? Is there anything I can do to help with it if it happens again?