Yes, you get an error message if you try to run an OS X update, if it is for a higher version of OS X.
And, upgrading such a small amount (from Mountain Lion to Mavericks) is somewhat counterproductive - you may need to upgrade again in literally a few months when a new macOS version is released (and your operating system falls further behind.)
I would suggest, when you have 10.8.5, that you move to Yosemite (OS X 10.10.5), which will be a substantial upgrade, yet not such as large change overall. It will keep you going another few years (or should
)
I should mention two other upgrades that you could do at the same time (which will take you a big step forward with how fast your system feels) Upgrade the RAM to 8GB (or to 16GB, but that's not as great a leap as 8GB is from 4GB), and replace your spinning hard drive with an SSD.
Prices for those have dropped significantly in the last couple of years, and particularly the SSD will make obvious difference in how fast your MacBookpro feels. It will literally feel like a brand new laptop (and faster than when you first started using it
)
(just something for you consider doing)