Mathematics classrooms are typically characterized by considerable heterogeneity with respect to students' knowledge and skills. Mathematics teachers need to be highly attentive to students' thinking, learning difficulties, and any misconceptions that they may develop. Identification of potential errors and appropriate ways to approach them is crucial for attaining positive learning outcomes. This paper explores which knowledge and affective-motivational skills teachers most require to effectively identify and approach students' errors. To address this research question within the German follow-up study of the Teacher Education and Development Study in Mathematics (TEDS-M), 131 primary school mathematics teachers' ability to identify students' errors was assessed based on (a) a digitalized speed test showing different students' solutions in a written notation and (b) three video vignettes that showed different scenes from mathematics classes. These scenes dealt, among other things, with children who struggled with the lesson's mathematical content. Teachers were asked to analyze students' thinking and to determine how best to react. In addition, teachers' mathematics pedagogical content knowledge, mathematical content knowledge, and beliefs were assessed in separate tests and served as predictors for teachers' abilities to identify, analyze, and deal with students' errors. The results indicate that all components are interrelated. However, path analysis reveals that teachers' ability to deal with students' errors is mainly predicted by their constructivist beliefs while their ability to quickly identify typical students' errors is largely dependent on their mathematics content knowledge. The results show the central filtering function of beliefs. Teachers who believe that students must shape and create their own learning processes are more successful in perceiving and analyzing student errors in classroom situations. They may understand errors as learning opportunities and - thus - pay specific attention to these occurrences.