Added exception safe string.format function.