Save error message

@param  array  error
@return false
@author Dmitry(dio) Levashov
484197
protected function setError($error) {
		
		$this->error = array();
		
		foreach (func_get_args() as $err) {
			if (is_array($err)) {
				$this->error = array_merge($this->error, $err);
			} else {
				$this->error[] = $err;
			}
		}
		
		// $this->error = is_array($error) ? $error : func_get_args();
		return false;
	}
27113
public function formatErrors(array $errors)
   {
      $tmp = [];
      $len = count($errors);
      if ($len === 0) {
         throw new InvalidArgumentException(
            "invalid value provided for 'errors'; expecting an array that ".
            "contains at least one instance of sndsgd\\field\\Error"
         );
      }

      $noun = ($len === 1) ? 'option' : 'options';
      $tmp = ["failed to process $noun"];
      foreach ($errors as $error) {
         $name = $error->getName();
         $message = $error->getMessage();
         if (!array_key_exists($name, $tmp)) {
            $tmp[$name] = " @[bold]$name@[reset] → $message";
         }
      }
      return implode(PHP_EOL, array_values($tmp)).PHP_EOL;
   }
97420
public function save(array $options = [])
    {
        try {
            // Save model to database
            $result = parent::save($options);

            // If save has been aborted from an event/observer
            // or simply returned an empty response, we'll treat
            // it as a failed save and throw an exception.
            if (! $result) {
                throw new SaveFailedException(sprintf('Could not save model [%s]. Reason: Save returned false.', get_class($this)));
            }
        } catch (Exception $e) {
            // Catch exceptions and re-throw
            // as our Nodes "save failed" exceptions
            throw (new SaveFailedException(sprintf('Could not save model [%s]. Reason: %s', get_class($this), $e->getMessage())))->setPreviousException($e);
        } catch (Throwable $e) {
            // Add support for PHP 7 throwable interface.
            // Re-throw as our Nodes "save failed" exceptions.
            throw (new SaveFailedException(sprintf('Could not save model [%s]. Reason: %s', get_class($this), $e->getMessage())))->setPreviousException($e);
        }

        return $result;
    }
1006062
protected function renderErrorsAsMarkupList(array $errors) {
		$markup = '';
		foreach ($errors as $error) {
			$markup .= '- Error code: ' . $error->getCode() . ' - ' . $error->getMessage() . PHP_EOL;
		}
		return TRUE === empty($markup) ? '' : PHP_EOL . $markup;
	}
897570
public static function createUsingErrors(array $errors)
    {
        $message = "An error was encountered reading an XML document:\n";

        foreach ($errors as $error) {
            switch ($error->level) {
                case LIBXML_ERR_ERROR:
                    $message .= '[Error] ';
                    break;
                case LIBXML_ERR_FATAL:
                    $message .= '[Fatal] ';
                    break;
                case LIBXML_ERR_WARNING:
                    $message .= '[Warning] ';
                    break;
            }

            $message .= sprintf(
                "[line %d] [column %d] %s in \"%s\".\n",
                $error->line,
                $error->column,
                trim($error->message),
                $error->file
            );
        }

        return new self($message);
    }
650362
public static function save($array, $filename) {
		$content = "<?php\nreturn " . self::asPhpArray ( $array, "array", 1, true ) . ";";
		return UFileSystem::save ( $filename, $content );
	}
727914
private function hasError(array $response): bool
    {
        if (isset($response[self::ERROR])) {
            $this->errorMessage = $response[self::ERROR][self::ERROR_MESSAGE] ?? null;
            $this->errorType = $response[self::ERROR][self::ERROR_TYPE] ?? null;
            $this->errorCode = $response[self::ERROR][self::ERROR_CODE] ?? null;
            $this->errorSubcode = $response[self::ERROR][self::ERROR_SUBCODE] ?? null;
            $this->errorFbtraceId = $response[self::ERROR][self::ERROR_FBTRACE_ID] ?? null;

            return true;
        }

        return false;
    }
1059731
private function wpErrorFor(array $errors, array $response): WP_Error
    {
        $wpError = new WP_Error;
        foreach ($errors as $error) {
            $wpError->add($error['code'], $error['message'], $response);
        }

        return $wpError;
    }
89444
protected function sendAjaxError($error)
    {
        if ($this->getRequest()->is('json')) {
            $this->getResponse()->withStatus(500);
            $response = [
                'status' => APP_OFF,
                'msg' => $error->getMessage()
            ];
            $this->set(compact('response'));
            $this->render('/Error/errorjson');
        }
    }
551900
private function formatErrorMessage(array $error) {
        if (isset($error['messageCode'])) {
            $messageCode = $error['messageCode'];
        } elseif (isset($error['message'])) {
            return $error['message'];
        } else {
            $messageCode = $error['error'];
        }

        // Massage the field name for better formatting.
        $msg = $this->formatMessage($messageCode, $error);
        return $msg;
    }
249810
public function error(array $errors): Response
    {
        $this->response->setStatus(500);
        $this->response->setBody(json_encode(['errors' => $errors]));
        return $this->response;
    }
1025201
def save_error(message)
      path = error_file_path
      FileUtils.mkdir_p File.dirname(path)
      File.open(path, 'w') { |f| f.write message }
      warn "API request failed! log can be found in #{path}"
    end
176443
function (errors, throwsErrors) {
                if (errors.length === 0) {
                    return true;
                }
                if (!throwsErrors) {
                    for (var i = 0; i < errors.length; i++) {
                        this.$logError(errors[i].msgId, errors[i].msgArgs);
                    }
                } else {
                    var error, logs = aria.core.Log;
                    // aria.core.Log may not be available
                    if (logs) {
                        var messages = [];
                        for (var i = 0; i < errors.length; i++) {
                            errors[i].message = logs.prepareLoggedMessage(errors[i].msgId, errors[i].msgArgs);
                            messages.push(errors[i].message);
                        }
                        error = new Error(messages.join('\n'));
                    } else {
                        error = new Error();
                    }
                    error.errors = errors;
                    throw error;
                }
                return false;
            }
73148
protected void saveActionErrors( ActionMessages errors )
    {
        // Remove any messages attribute if none are required
        if ( errors == null || errors.isEmpty() )
        {
            getRequest().removeAttribute( Globals.ERROR_KEY );
        }
        else
        {
            getRequest().setAttribute( Globals.ERROR_KEY, errors );
        }
    }
430192
public function fromArray(array $error)
    {

        // extract the array with the error information
        list ($type, $message, $file, $line) = array_values($error);

        // initialize and return the error instance
        return new Error($type, $message, $file, $line);
    }
756921
protected function showErrors($errors)
    {
        $i = 0;
        $this->output->writeln("\nThere was ".count($errors).' errors:');

        foreach ($errors as $filename => $error) {
            $this->output->writeln('<comment>'.++$i.". {$filename}:{$error['line']}".'</comment>');

            $this->output->write($this->getHighlightedCodeSnippet($filename, $error['line']));

            $this->output->writeln("<error> {$error['error']}</error>");
        }
    }
1118901
public function save(array $options = [])
    {
        $query = $this->newModelQuery();

        // If the "saving" event returns false we'll bail out of the save and return
        // false, indicating that the save failed. This provides a chance for any
        // listeners to cancel save operations if validations fail or whatever.
        if ($this->fireModelEvent('saving') === false) {
            return false;
        }

        // If the model already exists in the database we can just update our record
        // that is already in this database using the current IDs in this "where"
        // clause to only update this model. Otherwise, we'll just insert them.
        if ($this->exists) {
            $saved = $this->isDirty() ?
                        $this->performUpdate($query) : true;
        }

        // If the model is brand new, we'll insert it into our database and set the
        // ID attribute on the model to the value of the newly inserted row's ID
        // which is typically an auto-increment value managed by the database.
        else {
            $saved = $this->performInsert($query);

            if (! $this->getConnectionName() &&
                $connection = $query->getConnection()) {
                $this->setConnection($connection->getName());
            }
        }

        // If the model is successfully saved, we need to do a few more things once
        // that is done. We will call the "saved" method here to run any actions
        // we need to happen after a model gets successfully saved right here.
        if ($saved) {
            $this->finishSave($options);
        }

        return $saved;
    }