Fix scope in print error message

Fix #605