BU-ISCIII / iskylims

is an open-source LIMS (laboratory Information Management System) for Next Generation Sequencing sample management, statistics and reports, and bioinformatics analysis service management.
https://github.com/BU-ISCIII/iSkyLIMS/wiki
GNU General Public License v3.0
72 stars 34 forks source link

Improve the error handling to homogize always the same behaviour #293

Closed luissian closed 1 month ago

luissian commented 2 months ago

Description of feature

This issue is open to split issue #131

Error handling:

There are heterogeneous ways when handling errors in the code. Some times raise exception is used and sometines only a return is used. We should change all of them to proper Exception defined clases. Proposal:

Inside the function:

 try:
                project_sample_data["user_id"] = samples_with_user_ids[sample]
            except KeyError as e:
                raise KeyError(33)

Error handling in main function:


try:
            process_and_store_samples_projects_data(sample_project_parsed_data, run_process_obj, experiment_name)
        except KeyError as key_error:
            string_message = experiment_name + ' : Error when processing and storing samples in projects.'
            logging_errors (string_message, True, False)
            if key_error.args[0] == 33:
                handling_errors_in_run (experiment_name, '33' )
            else:
                string_message = experiment_name + ' : Unknown error when processing and storing samples in projects.'
                logging_errors (string_message, True, False) 
            logger.debug('%s : End function manage_run_in_processed_bcl2fast2_run with error', experiment_name)
            continue
        except Exception as e:
            string_message = experiment_name + ' : Unknown error when processing and storing samples in projects.'
            logging_errors (string_message, True, False)
            continue

Maybe we could check if there it is known error in the database...or maybe there is another way. In any case we should check this way so we handle known and unknown errors and the code won't crush. We can talk about it.

luissian commented 1 month ago

It is planned for the next release to refactor the crontab for using classes to improve the maintenance and to implement the bclconvert output files