Skip to main content
Question

name 'BoxAPIException' is not defined

  • May 22, 2025
  • 2 replies
  • 37 views

Forum|alt.badge.img

My code is sorting and moving the files based on the file type. i am included a try and except block in case the file is already included in the folder, it should move to different folder. But i am getting below error

 

NameError                                 Traceback (most recent call last)
 in ()
     24 
     25 
---> 26         except BoxAPIException:
     27                 print('possible duplicate')
     28                 print('Copying ' + filesInEachFolder[j].name)

NameError: name 'BoxAPIException' is not defined

 Can someone help me with this issue

2 replies

Forum|alt.badge.img

The code worked when i changed my Exception class from BoxAPIException to Exception.

 


Forum|alt.badge.img

 You could also add the following code to your file, to ensure that the name is defined:

 

from boxsdk.exception import BoxAPIException