2019-04-01 13:07:22 +00:00
|
|
|
"""Custom exceptions."""
|
|
|
|
|
2018-12-19 10:19:07 +00:00
|
|
|
import re
|
|
|
|
|
|
|
|
|
|
|
|
class LaterError(Exception):
|
2019-04-01 13:07:22 +00:00
|
|
|
"""Generic exception for later."""
|
2018-12-19 10:19:07 +00:00
|
|
|
|
|
|
|
def __init__(self, msg, original):
|
2019-04-04 13:35:47 +00:00
|
|
|
"""Initialize new exception."""
|
2023-01-09 10:59:25 +00:00
|
|
|
super(LaterError, self).__init__(f"{msg}: {original}")
|
2018-12-19 10:19:07 +00:00
|
|
|
self.original = original
|
|
|
|
|
|
|
|
|
|
|
|
class LaterAnsibleError(Exception):
|
2019-04-01 13:07:22 +00:00
|
|
|
"""Wrapper for ansible syntax errors."""
|
2018-12-19 10:19:07 +00:00
|
|
|
|
|
|
|
def __init__(self, msg, original):
|
|
|
|
lines = original.message.splitlines()
|
|
|
|
|
2019-04-01 13:07:22 +00:00
|
|
|
line_no = re.search("line(.*?),", lines[2])
|
|
|
|
column_no = re.search("column(.*?),", lines[2])
|
2018-12-19 10:19:07 +00:00
|
|
|
|
|
|
|
self.message = lines[0]
|
|
|
|
self.line = line_no.group(1).strip()
|
|
|
|
self.column = column_no.group(1).strip()
|