format_error_val function

Format value for error message