public function testCreate() { // Create new processing error associated with a crash report $model = new ProcessingError(); $model->type = ProcessingError::TYPE_CRASH_REPORT_ERROR; $model->srcid = 100; $model->message = 'Some error message'; // srcid is incorrect $this->assertFalse($model->validate()); // Set correct srcid $model->srcid = 1; $saved = $model->save(); // Ensure created ok $this->assertTrue($saved); // Find created model $model = ProcessingError::model()->find('message="Some error message"'); $this->assertTrue($model != null); // Create new processing error associated with a debug info $model = new ProcessingError(); $model->type = ProcessingError::TYPE_DEBUG_INFO_ERROR; $model->srcid = 100; $model->message = 'Error message'; // srcid is incorrect $this->assertFalse($model->validate()); // Set correct srcid $model->srcid = 1; $saved = $model->save(); // Ensure created ok $this->assertTrue($saved); }
/** * Process condition and do action * @param Audit $audit Audit ORM * @param Handler $handler Handler ORM * @return boolean Return TRUE if successful, FALSE otherwise */ public function process(Audit $audit) { $this->_populateHandlers(); $ret = true; foreach ($this->_handlers as $handler) { $result = $this->_doProcess($handler, $audit); if ($result === false) { // log processing errors $processingError = new ProcessingError(); $processingError->_shouldAudit = false; $processingError->auditId = $audit->auditId; $processingError->handlerId = $handler->handlerId; $processingError->persist(); } $ret &= $result; } return $ret; }
/** * Process condition and do action * @param Handler $handler Handler ORM * @param Audit $audit Audit ORM * @return boolean Return TRUE if successful, FALSE otherwise */ public function process(Audit $audit) { $this->_populateHandlers(); $data = DataIntegration::handlerSSSourceData($audit); if (isset($data['_audit'])) { DataIntegration::handlerSSAct($audit, $data); } $ret = true; foreach ($this->_handlers as $handler) { $result = $this->_doProcess($handler, $audit); if ($result === false) { // log processing errors $processingError = new ProcessingError(); $processingError->_shouldAudit = false; $processingError->auditId = $audit->auditId; $processingError->handlerId = $handler->handlerId; $processingError->persist(); } $ret |= $result; } return $ret; }
/** * Returns the list of processing errors associated with this crash report. */ public function getProcessingErrors() { $criteria = new CDbCriteria(); $criteria->compare('srcid', $this->id); $criteria->compare('type', ProcessingError::TYPE_CRASH_REPORT_ERROR); $models = ProcessingError::model()->findAll($criteria); return $models; }
/** * Tests that the processing error class extracts the source filename from * a given exception message, * * @param string $message The original exception message * * @return void * @dataProvider getParserExceptionMessages */ public function testGetFileReturnsExpectedFileName($message) { $processingError = new ProcessingError($message); $this->assertEquals('/tmp/foo.php', $processingError->getFile()); }
/** * Adds a single ProcessingError. * * @since 0.4 * * @param string $errorMessage * @param integer $severity */ public static function addError(ProcessingError $error) { self::$errors[$error->getElement()][] = $error; }
/** * Creates a processing error record and associates it with a crash report or * with a debug info * @param integer $type Error type. * @param integer $srcid Crash report ID or debug info ID. * @param string $message Error message. * @return void */ private function addProcessingError($type, $srcid, $message) { $processingError = new ProcessingError(); $processingError->type = $type; $processingError->srcid = $srcid; $processingError->message = $message; if (!$processingError->save()) { Yii::log('Couldnot save processing error record', 'error'); } }