diff --git a/SAS/TMSS/client/lib/mains.py b/SAS/TMSS/client/lib/mains.py
index f817a3fc21cd4a6dcd91793ea9b9e256f9c9bc39..4b6ea7e3816ee12ba79957f1f2a2f3fd370c0380 100644
--- a/SAS/TMSS/client/lib/mains.py
+++ b/SAS/TMSS/client/lib/mains.py
@@ -99,12 +99,13 @@ def main_set_subtask_state():
     parser = argparse.ArgumentParser()
     parser.add_argument("subtask_id", type=int, help="The ID of the TMSS subtask to set the status on")
     parser.add_argument("state", help="The state to set")
+    parser.add_argument('-e', '--error_reason', default=None, help="Optional error message string when setting a subtask to error.")
     parser.add_argument('-R', '--rest_api_credentials', type=str, default='TMSSClient', help='TMSS django REST API credentials name, default: TMSSClient')
     args = parser.parse_args()
 
     try:
         with TMSSsession.create_from_dbcreds_for_ldap(dbcreds_name=args.rest_api_credentials) as session:
-            changed_subtask = session.set_subtask_status(args.subtask_id, args.state)
+            changed_subtask = session.set_subtask_status(args.subtask_id, args.state, args.error_reason)
             print("%s now has state %s, see: %s" % (changed_subtask['id'], changed_subtask['state_value'], changed_subtask['url']))
     except Exception as e:
         print(e)
diff --git a/SAS/TMSS/client/lib/tmss_http_rest_client.py b/SAS/TMSS/client/lib/tmss_http_rest_client.py
index 6e6fb09ba50f1ee162844925e4dde8fe332c4835..460154cb0ea777d816fb1fc757b547f81a39ac7b 100644
--- a/SAS/TMSS/client/lib/tmss_http_rest_client.py
+++ b/SAS/TMSS/client/lib/tmss_http_rest_client.py
@@ -151,11 +151,14 @@ class TMSSsession(object):
         except:
             pass
 
-    def set_subtask_status(self, subtask_id: int, status: str) -> {}:
+    def set_subtask_status(self, subtask_id: int, status: str, error_reason=None) -> {}:
         '''set the status for the given subtask, and return the subtask with its new state, or raise on error'''
         json_doc = {'state': "%s/subtask_state/%s/" % (self.api_url, status)}
         if status == 'finishing' or status == 'cancelling':
             json_doc['scheduled_on_sky_stop_time'] = datetime.utcnow().isoformat()
+        if status == 'error':
+            hostname = socket.gethostname()
+            json_doc['error_reason'] = error_reason if error_reason is not None else f"set to error via REST client on host '{hostname}'"
         logger.info("updating subtask id=%s status to '%s'", subtask_id, status)
         response = self.session.patch(url='%s/subtask/%s/' % (self.api_url, subtask_id),
                                       json=json_doc)