Skip to content

[Import] [Ref] [Minor] Simplify error handling with a try-catch block #23370

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 5, 2022

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented May 5, 2022

Overview

[Import] [Ref] [Minor] Simplify error handling with a try-catch block

Before

Repetitve error handling & return points ...

multiple cases of

  array_unshift($values, $errorMessage);
  $this->setImportStatus($rowNumber, 'ERROR', $errorMessage);
  return CRM_Import_Parser::ERROR;

After

The code chunk is wrapped in a try-catch eg.

  try {

  }
  catch (CRM_Core_Exception $e) {
    array_unshift($values, $errorMessage);
    $this->setImportStatus($rowNumber, 'ERROR', $errorMessage);
    return CRM_Import_Parser::ERROR;
  }

Technical Details

use w=1 link as a fair bit of whitespace

Comments

@civibot
Copy link

civibot bot commented May 5, 2022

(Standard links)

@civibot civibot bot added the master label May 5, 2022
@seamuslee001 seamuslee001 merged commit 5d7bfb5 into civicrm:master May 5, 2022
@seamuslee001 seamuslee001 deleted the import_catch branch May 5, 2022 06:00
@seamuslee001
Copy link
Contributor

Seems fine to me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants