Fix error dump to use C functions