<p>I have a custom action in a workflow and would like to report an error to the user when something goes wrong.  What's the best way of doing that?</p>

<p><strong>UPD:</strong> Ideally I would like to put the workflow in the error state and log a message to the workflow log.  That doesn't seem possible.  What's the closest I can get to it? I want to a reusable solution,something that's easy for users to set up when using my custom action in SharePoint Designer.</p>

<hr>

<p>Added more details to the question.</p>

<p>@mauro that takes care of storing the error, but how do I display the error to the user in a way which makes sense?</p>

<p>@AdamSane That's seems like a rather fragile solution.  It's not a matter of setting this up once on a single site.  I need something others can add using SPD.</p>

[{'answer_id': 16177, 'author': 'AdamSane', 'author_id': 805, 'author_profile': 'https://Stackoverflow.com/users/805', 'pm_score': 0, 'selected': False, 'text': '<p>Add the error to a hidden list with that users name. Set the visibility on the list (for users) to only read/write their own values. Then use a custom web part or FlexListViewer to view the contents of that list and display it to the user. Once they acknowledge that error, remove it from the list.</p>\n\n<p>If necessary, you can add a different workflow action on that message list, that says pause for 2 days and then email. Whatever, depending on your requirements.</p>\n\n<p>Otherwise you can have a custom db table that you use for pretty much the same thing, this way sharepoint does most of the work for you.</p>\n\n<p><strong>Update</strong> This can be packaged up as a feature and deployed to each site as needed. The strengths of this approach (adding a list item to a list, querying, alerting a user, and emailing a user) are all built into the sharepoint itself. In this case you can focus on your custom logic only, while letting sharepoint focus on the implementation details.</p>\n'}, {'answer_id': 16272, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': '<p>Personally I would log it to either a log file or the event log depending on the issue.  I think storing it using a users permissions would be a bad idea, what happens if that user does not have the correct rights? or worse still they get elevated permissions by browsing the list in explorer view? </p>\n\n<p>The log file would be the best way, that way you rely only on the file system being available - you dont have to worry about trapping errors happening whilst connecting to the database etc.</p>\n\n<p>Mauro</p>\n'}, {'answer_id': 16553, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 1, 'selected': False, 'text': '<p>when you throw the error your error handler can then email the user, or better if the list is massive, add the error state to the workflow item - i think this is default functionality though as the error would be mentioned there.</p>\n\n<p><a href="http://www.sharepointsecurity.com/blog/sharepoint/sharepoint-2007-development/fault-handling-in-sharepoint-workflows/" rel="nofollow noreferrer">http://www.sharepointsecurity.com/blog/sharepoint/sharepoint-2007-development/fault-handling-in-sharepoint-workflows/</a></p>\n'}, {'answer_id': 90884, 'author': 'Nat', 'author_id': 13813, 'author_profile': 'https://Stackoverflow.com/users/13813', 'pm_score': 0, 'selected': False, 'text': '<p>If you need the user to take some action as a result of the error (e.g. retrying the workflow) is it possible to create a task for that user with information on the error and the location of the workflow?</p>\n'}]
['https://Stackoverflow.com/questions/16145', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1533/']