Format the output in case of an error, replace the filename with sample.cpp