Skip to content

feat: Better error for programmers life#72

Open
guilleJB wants to merge 1 commit intomasterfrom
imp_fail_load_record_error
Open

feat: Better error for programmers life#72
guilleJB wants to merge 1 commit intomasterfrom
imp_fail_load_record_error

Conversation

@guilleJB
Copy link
Member

This pull request adds error handling to the load_data_records function in oopgrade/oopgrade.py to improve debugging and stability when loading records from XML. Now, if a record cannot be found, an error is logged and the exception is raised, making it easier to identify and troubleshoot issues during data import.

Error handling improvements:

  • Added try/except blocks around XML record lookups for both single and multiple records, logging an error message with the module and record ID before re-raising the exception.

try:
recs = doc.findall("//*[@id='{}']".format(record_id))
except Exception as e:
logger.error('{}: Failing find record id {}'.format(module_name, record_id))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aquest no fallarà mai, perquè simplement recs serà [] a l'altre sí perquè intentem accedir a la posició [0], potser aquí seria comprovar que recs no sigui buit.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ecarreras Millor que peti i et salti el LOG perquè sino ens pensem que actualitzem algun id i llavors no hi és. L'altres l'he posat sense mirar així que si podem fer-ho saltar si no troba cap registre enlloc del try 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants