diff --git a/classes/local/manager/process_manager.php b/classes/local/manager/process_manager.php
index 1c3c74a1cf8bafb5df76241eda72bb8958a60c9c..4d4b5786dc11f0b155ff112fa7d3a626fa85fa74 100644
--- a/classes/local/manager/process_manager.php
+++ b/classes/local/manager/process_manager.php
@@ -260,7 +260,7 @@ class process_manager {
         $procerror = (object) clone $process;
         $procerror->errormessage = get_class($e) . ': ' . $e->getMessage();
         $procerror->errortrace = $e->getTraceAsString();
-        $procerror->errortime = time();
+        $procerror->errortimecreated = time();
         $m = '';
         foreach ($e->getTrace() as $v) {
             $m .= $v['file'] . ':' . $v['line'] . '::';
@@ -284,7 +284,7 @@ class process_manager {
         unset($process->errormessage);
         unset($process->errortrace);
         unset($process->errorhash);
-        unset($process->errortime);
+        unset($process->errortimecreated);
 
         $DB->insert_record_raw('tool_lifecycle_process', $process, false, false, true);
         $DB->delete_records('tool_lifecycle_proc_error', ['id' => $process->id]);
@@ -303,7 +303,7 @@ class process_manager {
         unset($process->errormessage);
         unset($process->errortrace);
         unset($process->errorhash);
-        unset($process->errortime);
+        unset($process->errortimecreated);
 
         $DB->insert_record_raw('tool_lifecycle_process', $process, false, false, true);
         $DB->delete_records('tool_lifecycle_proc_error', ['id' => $process->id]);
diff --git a/classes/task/lifecycle_error_notify_task.php b/classes/task/lifecycle_error_notify_task.php
index ec631a4f059d20995e7a3ecb997cd9620f9c0cf3..3f643a41da8cb402243d7963f5172d7da78bd2fc 100644
--- a/classes/task/lifecycle_error_notify_task.php
+++ b/classes/task/lifecycle_error_notify_task.php
@@ -57,7 +57,8 @@ class lifecycle_error_notify_task extends \core\task\scheduled_task {
 
         $currenttime = time();
 
-        $errorcount = $DB->count_records_select('tool_lifecycle_proc_error', 'errortime > :lastrun', ['lastrun' => $lastrun]);
+        $errorcount = $DB->count_records_select('tool_lifecycle_proc_error', 'errortimecreated > :lastrun',
+                ['lastrun' => $lastrun]);
 
         set_config('adminerrornotifylastrun', $currenttime, 'tool_lifecycle');
 
diff --git a/db/install.xml b/db/install.xml
index 22f2fa0f655b87debb931afafb36e5b76e639826..c8940a4b4c2c8bf445ea60f59337dcd699b2acdf 100644
--- a/db/install.xml
+++ b/db/install.xml
@@ -157,7 +157,7 @@
         <FIELD NAME="errormessage" TYPE="text" NOTNULL="true" SEQUENCE="false" COMMENT="Message of the error"/>
         <FIELD NAME="errortrace" TYPE="text" NOTNULL="true" SEQUENCE="false"/>
         <FIELD NAME="errorhash" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" COMMENT="Where the error occured in the form 'path/to/filename.php:line'"/>
-        <FIELD NAME="errortime" TYPE="int" LENGTH="11" NOTNULL="true" SEQUENCE="false" COMMENT="unix timestamp - time the error occured"/>
+        <FIELD NAME="errortimecreated" TYPE="int" LENGTH="11" NOTNULL="true" SEQUENCE="false" COMMENT="unix timestamp - time the error occured"/>
       </FIELDS>
       <KEYS>
         <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
diff --git a/db/upgrade.php b/db/upgrade.php
index a0a11f6e3ef63a8bbcbacb9b294ef7940db7df4d..5e0c0cbd6c51672131050ec310bda3053a9cb79a 100644
--- a/db/upgrade.php
+++ b/db/upgrade.php
@@ -461,7 +461,7 @@ function xmldb_tool_lifecycle_upgrade($oldversion) {
         $table->add_field('errormessage', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL, null, null);
         $table->add_field('errortrace', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL, null, null);
         $table->add_field('errorhash', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
-        $table->add_field('errortime', XMLDB_TYPE_INTEGER, '11', null, XMLDB_NOTNULL, null, null);
+        $table->add_field('errortimecreated', XMLDB_TYPE_INTEGER, '11', null, XMLDB_NOTNULL, null, null);
 
         // Adding keys to table tool_lifecycle_proc_error.
         $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
diff --git a/tests/process_error_test.php b/tests/process_error_test.php
new file mode 100644
index 0000000000000000000000000000000000000000..5626b899dd68dfc3818dc5d6353a7b173207fd90
--- /dev/null
+++ b/tests/process_error_test.php
@@ -0,0 +1,116 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Checks whether process errors are properly inserted into the table.
+ *
+ * @package    tool_lifecycle
+ * @category   test
+ * @group      tool_lifecycle
+ * @copyright  2022 Justus Dieckmann WWU
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+namespace tool_lifecycle;
+
+use tool_lifecycle\local\entity\trigger_subplugin;
+use tool_lifecycle\local\manager\settings_manager;
+use tool_lifecycle\local\manager\workflow_manager;
+use tool_lifecycle\local\manager\trigger_manager;
+use tool_lifecycle\local\manager\process_manager;
+
+/**
+ * Checks whether process errors are properly inserted into the table.
+ *
+ * @package    tool_lifecycle
+ * @category   test
+ * @group      tool_lifecycle
+ * @copyright  2022 Justus Dieckmann WWU
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class process_error_test extends \advanced_testcase {
+    /** Icon of the manual trigger. */
+    const MANUAL_TRIGGER1_ICON = 't/up';
+    /** Display name of the manual trigger. */
+    const MANUAL_TRIGGER1_DISPLAYNAME = 'Up';
+    /** Capability of the manual trigger. */
+    const MANUAL_TRIGGER1_CAPABILITY = 'moodle/course:manageactivities';
+
+
+    /** @var trigger_subplugin $trigger Instances of the triggers under test. */
+    private $trigger;
+    /** @var array $course Instance of the course under test. */
+    private $course;
+
+    /**
+     * Setup the testcase.
+     * @throws \coding_exception
+     * @throws \moodle_exception
+     */
+    public function setUp() : void {
+        global $USER, $DB;
+
+        // We do not need a sesskey check in theses tests.
+        $USER->ignoresesskey = true;
+
+        $this->resetAfterTest(true);
+        $generator = $this->getDataGenerator()->get_plugin_generator('tool_lifecycle');
+        $triggersettings = new \stdClass();
+        $triggersettings->icon = self::MANUAL_TRIGGER1_ICON;
+        $triggersettings->displayname = self::MANUAL_TRIGGER1_DISPLAYNAME;
+        $triggersettings->capability = self::MANUAL_TRIGGER1_CAPABILITY;
+        $manualworkflow = $generator->create_manual_workflow($triggersettings);
+        $step = $generator->create_step("instance1", "deletecourse", $manualworkflow->id);
+        settings_manager::save_settings($step->id, settings_type::STEP, "deletecourse",
+                array("maximumdeletionspercron" => 10)
+        );
+
+        workflow_manager::handle_action(action::WORKFLOW_ACTIVATE, $manualworkflow->id);
+
+        $this->course = $this->getDataGenerator()->create_course();
+        $this->getDataGenerator()->create_module('page', ['course' => $this->course->id]);
+
+        // Corrupt course.
+        $DB->execute('UPDATE {course_modules} SET instance = 0');
+        $this->trigger = trigger_manager::get_triggers_for_workflow($manualworkflow->id)[0];
+    }
+
+    /**
+     * Test if the correct process error was put into the table.
+     */
+    public function test_process_error_in_table() {
+        global $DB;
+        $process = process_manager::manually_trigger_process($this->course->id, $this->trigger->id);
+
+        // The delete course step really wants to print output.
+        ob_start();
+        $processor = new processor();
+        $processor->process_courses();
+        ob_end_clean();
+
+        $records = $DB->get_records('tool_lifecycle_proc_error');
+
+        $this->assertEquals(1, count($records));
+        $this->assertEquals(0, $DB->count_records('tool_lifecycle_process'));
+
+        $record = reset($records);
+
+        $this->assertEquals($this->course->id, $record->courseid);
+        $this->assertStringContainsString("Trying to get property 'id' of non-object", $record->errormessage);
+        $this->assertEquals($process->id, $record->id);
+    }
+
+}