Printing error stack and infering types