Skip to content

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

@luissian

Description

@luissian

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.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions