diff --git a/lib/classes/antivirus/manager.php b/lib/classes/antivirus/manager.php
index d17c42e0760..4537c56914e 100644
--- a/lib/classes/antivirus/manager.php
+++ b/lib/classes/antivirus/manager.php
@@ -106,7 +106,18 @@ class manager {
                 if ($deleteinfected) {
                     unlink($file);
                 }
-                throw new \core\antivirus\scanner_exception('virusfound', '', array('item' => $filename));
+
+                // Get custom message to display to user from antivirus engine.
+                $displaymessage = $antivirus->get_virus_found_message();
+                $placeholders = array_merge(['item' => $filename], $displaymessage['placeholders']);
+
+                throw new \core\antivirus\scanner_exception(
+                    $displaymessage['string'],
+                    '',
+                    $placeholders,
+                    null,
+                    $displaymessage['component']
+                );
             } else if ($result === $antivirus::SCAN_RESULT_ERROR) {
                 // Here we need to generate a different incident based on an error.
                 $incidentdetails = $antivirus->get_incident_details($file, $filename, $notice, false);
@@ -163,7 +174,17 @@ class manager {
                 $event = \core\event\virus_infected_data_detected::create($params);
                 $event->trigger();
 
-                throw new \core\antivirus\scanner_exception('virusfound', '', array('item' => get_string('datastream', 'antivirus')));
+                // Get custom message to display to user from antivirus engine.
+                $displaymessage = $antivirus->get_virus_found_message();
+                $placeholders = array_merge(['item' => get_string('datastream', 'antivirus')], $displaymessage['placeholders']);
+
+                throw new \core\antivirus\scanner_exception(
+                    $displaymessage['string'],
+                    '',
+                    $placeholders,
+                    null,
+                    $displaymessage['component']
+                );
             } else if ($result === $antivirus::SCAN_RESULT_ERROR) {
                 // Here we need to generate a different incident based on an error.
                 $incidentdetails = $antivirus->get_incident_details('', $filename, $notice, false);
diff --git a/lib/classes/antivirus/scanner.php b/lib/classes/antivirus/scanner.php
index c12d6a5771d..535942602ce 100644
--- a/lib/classes/antivirus/scanner.php
+++ b/lib/classes/antivirus/scanner.php
@@ -238,4 +238,14 @@ abstract class scanner {
     public function get_messages() : array {
         return $this->messages;
     }
+
+    /**
+     * Getter method for the antivirus message displayed in the exception.
+     *
+     * @return array array of string and component to pass to exception constructor.
+     */
+    public function get_virus_found_message() {
+        // Base antivirus found string.
+        return ['string' => 'virusfound', 'component' => 'antivirus', 'placeholders' => []];
+    }
 }