Is there any way to simulate a transaction without sending it to the blockchain and find the exact error (or line of code), in case it fails if its mined?
--maxpeers would work, as would shutting off your network connection to the Internet. If you want to mine, you will have to run a miner, either in
geth or a GPU miner like
ethminer. But note that the difficulty set in the public network blockchain is very high as this difficulty is adjusted to cater for the many thousands of computers mining the public blockchain.
Once you shut off your connection from the public network and switch on your mining, it will take a very very long time for your single miner to solve a block. But if you leave your private mining operation on for another very very long time, the difficulty will adjust downward back so your single miner mining blocks every 15 seconds.
If you are want to try creating smart contracts, your easiest path is to spin up a Dev blockchain. This will just run on your local computer and you can set it to mine to receive some ethers in your account so you can use it to send the contract creation transactions.
See Deploying the Greeter contract via the geth CLI is not registering in my private blockchain for an example of deploying contracts to a Dev blockchain.
--dev parameter will tell
geth that you want to only run a Dev blockchain. The
--minerthreads 1 parameters will tell your
geth instance to mine the blockchain.
The difficulty is set low so you will mine blocks quite frequently.
Solidity didn't offer an exception management mechanism as try/catch (for Java/c#).
due to an invalid EVM code, throw consumes all provided gas terminates and reverts all changes to the state made by current contract execution and to Ether balances. this concept intends to prevent spamming the network.
in the Yellow paper it is mentioned that :
Just as with contract creation, if the execution halts in an exceptional fashion (i.e. due to an exhausted gas supply, stack underflow, invalid jump destination or invalid instruction), then no gas is refunded to the caller and the state is reverted to the point immediately prior to balance transfer (i.e. σ)
as an information for the “intrinsic gas too low” message
Mist checks the amount gas without executing any code and it tells you that the transaction will fail because you didn't provide enough gas to execute the transaction.