import json


class StepException(Exception):
    def __str__(self):
        return self.errors

    def __init__(self, context, errors=''):
        self.errors = errors
        self.id = ''
        try:
            self.id = context.xml.xpath('iati-identifier/text()')[0]
        except:
            pass

    @property
    def json_output(self):
        return json.dumps({
            'errors': self.errors,
            'id': self.id,
        })

@@ -386,22 +386,18 @@
    '
-errors
+id
 ': self.
 erro
@@ -392,22 +392,18 @@
 ': self.
-errors
+id
 ,%0A      
@@ -405,34 +405,38 @@
            '
-id
+errors
 ': self.
 id,%0A        
@@ -415,31 +415,35 @@
  'errors': self.
-id
+errors
 ,%0A        %7D)%0A

Reorder args