ansible-later/ansiblelater/exceptions.py

30 lines
711 B
Python
Raw Normal View History

"""Custom exceptions."""
2018-12-19 10:19:07 +00:00
import re
class LaterError(Exception):
"""Generic exception for later."""
2018-12-19 10:19:07 +00:00
def __init__(self, msg, original):
"""
Initialize new exception.
"""
2018-12-19 10:19:07 +00:00
super(LaterError, self).__init__(msg + (": %s" % original))
self.original = original
class LaterAnsibleError(Exception):
"""Wrapper for ansible syntax errors."""
2018-12-19 10:19:07 +00:00
def __init__(self, msg, original):
lines = original.message.splitlines()
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()