sets error code returned by pgsql
326087
private function SetErrCode()
    {
        $connection_status = @pg_connection_status($this->conn);
        $last_error = @pg_last_error($this->conn);
        $result_error = @pg_result_error($this->conn);
        $last_notice = @pg_last_notice($this->conn);

        $_errors = array();

        if ($connection_status) {
            $_errors[] = ($connection_status?$connection_status:'');
        }
        if ($last_error) {
            $_errors[] = ($last_error?$last_error:'');
        }
        if ($result_error) {
            $_errors[] = ($result_error?$result_error:'');
        }
        if ($last_notice) {
            $_errors[] = ($last_notice?$last_notice:'');
        }

        if (count($_errors) > 0) {
            //$this->errStr .= '<div style="border:1px solid black; margin:4px; padding:4px; background-color:#FFDEAD;"><b>Query:</b> '.$this->last_query . '<br />'.implode('<br />', $_errors)."</div>";
            if ($_REQUEST[act]=='api') {
                foreach ($_errors as $_error) {
                    $lines=explode("\n", $_error);
                    $api_errors[]=$lines;
                }
                $err_string=json_encode(['error'=>'DB_error','errors'=>$api_errors]);//exit;
            } else {
                $err_string='<div class="alert alert-error"><h2>DB Error</h2><b>Query:</b> '.$this->last_query . '<br /><pre class="red">'.implode('<br />', $_errors)."</pre></div>";
            }
            $this->errStr .= $err_string;
            //$this->errStr .="<pre>".print_r($GLOBALS)."</pre>";
            $GLOBALS[no_refresh]=1;
        }
    }
334444
function privErrorLog($p_error_code=0, $p_error_string='')
  {
    if (PCLZIP_ERROR_EXTERNAL == 1) {
      PclError($p_error_code, $p_error_string);
    }
    else {
      $this->error_code = $p_error_code;
      $this->error_string = $p_error_string;
    }
  }
442087
function isConflictError (err) {
    // return false if err is not an object
    if (typeof err !== 'object') {
        return false
    }
    // return false if error does not have mysql duplicate key code
    if (err.errno !== 1062) {
        return false
    }
    // return false if duplicate key error is not on parent id column
    if (err.message.indexOf(this.model.columnName('parentId')) === -1) {
        return false
    }
    // if all negative tests pass return true
    return true
}
382314
def gpg_error(exception, message):
    """"""
    LOGGER.debug("GPG Command %s", ' '.join([str(x) for x in exception.cmd]))
    LOGGER.debug("GPG Output %s", exception.output)
    raise CryptoritoError(message)
617657
function(code, err, message) {
		code = (code || isNaN(code)) ? code : 500;
		err = (err) ? err : '';
		message = (message) ? message : '';

		return {
			'code': code,
			'error': err,
			'message': message
		};
	}
903717
function (connectionInfo, query, params) {
    var connection,
        client = new pg.Client(connectionInfo);

    client.connect(function (err) {
        if (err) {
            return respond({
                success: false,
                data: {
                    err: err,
                    query: query,
                    connection: connectionInfo
                }
            });
        }

        // execute a query on our database
        client.query(query, params, function (err, result) {
            // close the client
            client.end();

            // treat the error
            if (err) {
                return respond({
                    success: false,
                    data: {
                        err: err,
                        query: query,
                        connection: connectionInfo
                    }
                });
            }
            
            // Return the respose
            return respond({
                success: true,
                data: result
            });
        });
    });
}
488306
def handle_exc(exc):
    

    err = ERRORS_TABLE.get(exc.pgcode)

    if err:
        abort(exceptions.InvalidQueryParams(**{
            'detail': err,
            'parameter': 'filter',
        }))

    abort(exceptions.DatabaseUnavailable)
186386
function parseError(e) {
  let sqlError = (e.source || e);
  if(e.code && e.code.indexOf('SQL') === 0) {
    e.ns = 'STORE.SQL';
  }
  if(typeof sqlError.name !== 'string' || sqlError.name.indexOf('Sequelize') !== 0) return;
  e.ns = 'STORE.SQL';
  switch(sqlError.name) {
    case 'SequelizeUniqueConstraintError':
      e.code = 'VALIDATION_ERROR';
      break;
    case 'SequelizeDatabaseError':
      e.code = 'QUERY_ERROR';
      break;
    case 'SequelizeValidationError':
      e.code = 'VALIDATION_ERROR';
      e.statusCode = 400;
      try {
        e.message = sqlError.errors[0].message;
      } catch(er) {}
      break;
    default:
      e.code = 'DATABASE_ERROR';
  }
  return true;
}
38392
function setErrorStatus (error, status) {
  if (!error.status && !error.statusCode) {
    error.status = status
    error.statusCode = status
  }
}
904028
def pdu_to_function_code_or_raise_error(resp_pdu):
    
    function_code = struct.unpack('>B', resp_pdu[0:1])[0]

    if function_code not in function_code_to_function_map.keys():
        error_code = struct.unpack('>B', resp_pdu[1:2])[0]
        raise error_code_to_exception_map[error_code]

    return function_code
1036455
function setError( $connection = false )
    {
        if ( $this->IsConnected )
        {
            if ( $connection === false )
                $connection = $this->DBConnection;

            if ( $connection instanceof MySQLi )
            {
                $this->ErrorMessage = mysqli_error( $connection );
                $this->ErrorNumber = mysqli_errno( $connection );
            }
        }
        else
        {
            $this->ErrorMessage = mysqli_connect_error();
            $this->ErrorNumber = mysqli_connect_errno();
        }
    }
1336959
private function errorCode()
    {
        if ($this->preparedExec == false){
    		$returnValue = $this->dbConnector->errorCode();
    	}
    	else{
    		$returnValue = $this->lastPreparedExecStatement->errorCode();
    	}
        return (string) $returnValue;
    }
544732
public function error($key = null, $return_error = null, $return_no_error = '')
    {
        if (isset($key)) {
            $result = gplcart_array_get($this->errors, $key);
        } else {
            $result = empty($this->errors) ? null : $this->errors;
        }

        if (isset($result)) {
            return isset($return_error) ? $return_error : $result;
        }

        return $return_no_error;
    }
54140
private function tryToRecoverFromFailedQuery($sql, $arguments, $load_mode, $return_mode)
    {
        switch ($this->link->errno) {

            // Non-transactional tables not rolled back!
            case 1196:
                return null;

            // Server gone away
            case 2006:
            case 2013:
                return $this->handleMySqlGoneAway($sql, $arguments, $load_mode, $return_mode);

            // Deadlock detection and retry
            case 1213:
                return $this->handleDeadlock();

            // Other error
            default:
                throw new QueryException($this->link->error, $this->link->errno);
        }
    }
824251
function insertQueryError(err, tx) {
        CRUD.stats.writesExecuted++;
        console.error("Insert query error: ", err);
        return err;
    }
967602
private function _resetErrorMode()
    {
        // get PDO object and reset the error mode to what it was originally
        $pdo = $this->_getPdo();
        $pdo->setAttribute(PDO::ATTR_ERRMODE, $this->_errMode);
    }
782553
def set_errors(self):
		
		if not self.field.errors or self.attrs.get("_no_errors"):
			return
		
		self.values["class"].append("error")

		for error in self.field.errors:
			self.values["errors"] += ERROR_WRAPPER % {"message": error}