Morpheus Config Phase Error Messages

Morpheus spec modifications are an incredibly valuable tool to modify your instance configuration for a catalog item. I write in Python for these and wanted to have a way to display a nice error message in case of a problem.

try:
  response = requests.post(baseUrl +  getIpPath, json=postdata)
  response.raise_for_status()
  responseData = response.json()
  if 'subnets' in responseData:
    newIp = responseData['subnets'][0]['addresses'][0]['ip_addr']
  else:
    raise Exception("Bad response from API: " + json.dumps(responseData))
    
except Exception as e:
  sys.stderr.write("Error: " + str(e) + "\n")
  sys.exit(1)

This will raise an expected error and catch a general exception we weren't expecting. This will appear in the order history and will not build the instance: