@@ -64,5 +64,62 @@ suite('Error Classifier', () => {
6464 test ( 'should classify unrecognized errors as unknown' , ( ) => {
6565 assert . strictEqual ( classifyError ( new Error ( 'something went wrong' ) ) , 'unknown' ) ;
6666 } ) ;
67+
68+ test ( 'should classify PET restart failure as pet_crash' , ( ) => {
69+ assert . strictEqual (
70+ classifyError (
71+ new Error (
72+ 'Python Environment Tools (PET) failed after 3 restart attempts. Check the Output panel.' ,
73+ ) ,
74+ ) ,
75+ 'pet_crash' ,
76+ ) ;
77+ } ) ;
78+
79+ test ( 'should classify PET currently restarting as pet_crash' , ( ) => {
80+ assert . strictEqual (
81+ classifyError ( new Error ( 'Python Environment Tools (PET) is currently restarting. Please try again.' ) ) ,
82+ 'pet_crash' ,
83+ ) ;
84+ } ) ;
85+
86+ test ( 'should classify PET stdio failure as pet_crash' , ( ) => {
87+ assert . strictEqual ( classifyError ( new Error ( 'Failed to create stdio streams for PET process' ) ) , 'pet_crash' ) ;
88+ } ) ;
89+
90+ test ( 'should classify missing PET binary as pet_not_found' , ( ) => {
91+ assert . strictEqual ( classifyError ( new Error ( 'Python extension not found' ) ) , 'pet_not_found' ) ;
92+ } ) ;
93+
94+ test ( 'should classify wrapped spawn ENOENT as spawn_enoent' , ( ) => {
95+ assert . strictEqual ( classifyError ( new Error ( 'Error spawning conda: spawn conda ENOENT' ) ) , 'spawn_enoent' ) ;
96+ } ) ;
97+
98+ test ( 'should classify wrapped spawn EACCES as permission_denied' , ( ) => {
99+ assert . strictEqual (
100+ classifyError ( new Error ( 'Error spawning python: spawn python EACCES' ) ) ,
101+ 'permission_denied' ,
102+ ) ;
103+ } ) ;
104+
105+ test ( 'should classify wrapped spawn with other cause as spawn_error' , ( ) => {
106+ assert . strictEqual ( classifyError ( new Error ( 'Error spawning uv: some unexpected failure' ) ) , 'spawn_error' ) ;
107+ } ) ;
108+
109+ test ( 'should classify non-zero exit code failures as tool_exec_failed' , ( ) => {
110+ assert . strictEqual (
111+ classifyError ( new Error ( 'Failed to run "conda info --envs --json":\n conda not initialized' ) ) ,
112+ 'tool_exec_failed' ,
113+ ) ;
114+ assert . strictEqual ( classifyError ( new Error ( 'Failed to run uv pip install numpy' ) ) , 'tool_exec_failed' ) ;
115+ assert . strictEqual ( classifyError ( new Error ( 'Failed to run poetry install' ) ) , 'tool_exec_failed' ) ;
116+ } ) ;
117+
118+ test ( 'should classify invalid data type errors as parse_error' , ( ) => {
119+ assert . strictEqual (
120+ classifyError ( new Error ( 'conda info returned invalid data type: string' ) ) ,
121+ 'parse_error' ,
122+ ) ;
123+ } ) ;
67124 } ) ;
68125} ) ;
0 commit comments