Answers.Body: <p>You're getting <code>"Couldn’t save the new user: Array"</code> because <code>$newUser-&gt;getErrors()</code> returns an array of validation errors (in case there are more than one).</p>
  
  <p>If you want to print them all to a log file, you can do something like this:</p>
  
  <pre><code>AutoUserEntryPlugin::log('Couldn't save the new user: '.implode(', ', $newUser-&gt;getErrors()), LogLevel::Info);
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-09T09:17:45.740Z
Answers.Text: If I use
  
      AutoUserEntryPlugin::log('Couldn’t save the new user: '.implode(', ', $newUser->getErrors()), LogLevel::Info);
  
  I get an error on that line;
  
  PHP notice
  Array to string conversion
  
  [edit: how do you get line breaks in these comments?!]
Answers.UserDisplayName: Matt Wilcox
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-06T16:56:16.043Z
Answers.LastActivityDate: 2016-05-06T16:56:16.043Z
Answers.UserDisplayName: Brad Bell
Body: <p>So I've wasted a day because I couldn't figure out how to get an error back from an action I'm using in a plugin...</p>
  
  <pre><code>$newUserSuccess = craft()-&gt;users-&gt;saveUser($newUser);
  </code></pre>
  
  <p><code>$newUserSuccess</code> was empty, and it turns out the reason was because the new user was trying to register with an existing user's email address, which fails. I could not figure out how to get any useful information back. I had tried this:</p>
  
  <pre><code>if (!$newUserSuccess)
  {
      AutoUserEntryPlugin::log('Couldn't save the new user: '.print_r($newUser-&gt;getErrors(), true), LogLevel::Info);
      throw new Exception(Craft::t('Couldnt save the user.'));
  }
  </code></pre>
  
  <p>but in the log all that was output was "Couldn’t save the new user: Array"</p>
  
  <p>How should I be doing this?</p>
  
Tags: <plugin-development>
Title: Getting errors while developing plugins
ThreadText: # Getting errors while developing plugins
  
  (Asked by: username_0 on 2016-05-06)
  
  So I've wasted a day because I couldn't figure out how to get an error back from an action I'm using in a plugin...
  
  ```
  $newUserSuccess = craft()->users->saveUser($newUser);
  
  ```
  
  `$newUserSuccess` was empty, and it turns out the reason was because the new user was trying to register with an existing user's email address, which fails. I could not figure out how to get any useful information back. I had tried this:
  
  ```
  if (!$newUserSuccess)
  {
      AutoUserEntryPlugin::log('Couldn't save the new user: '.print_r($newUser->getErrors(), true), LogLevel::Info);
      throw new Exception(Craft::t('Couldnt save the user.'));
  }
  
  ```
  
  but in the log all that was output was "Couldn’t save the new user: Array"
  
  How should I be doing this?
  
  **Tags:** plugin-development
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-05-06. Score: 2
  
  You're getting `"Couldn’t save the new user: Array"` because `$newUser->getErrors()` returns an array of validation errors (in case there are more than one).
  
  If you want to print them all to a log file, you can do something like this:
  
  ```
  AutoUserEntryPlugin::log('Couldn't save the new user: '.implode(', ', $newUser->getErrors()), LogLevel::Info);
  
  ```
  
  > **Comments:**
  > **username_0**: If I use      AutoUserEntryPlugin::log('Couldn’t save the new user: '.implode(', ', $newUser->getErrors()), LogLevel::Info);  I get an error on that line;  PHP notice Array to string conversion  [edit: how do you get line breaks in these comments?!]  
  
  ---
  
  