looking for error id in OnException

Hi,

I can see in service center that errors have guid identifiers. We are looking for a way to pass that error id to the end user in case something goes wrong.
This way, production users can just get a nice "Something went wrong" message, with a code by which they can contact us if the problem persists. that code would be the error guid id. But I'm not sure how we can obtain it in our OnException.

mvp_badge
MVP
Solution

Hi Gwen,

I think that GUID isn't generated until it is saved in the database, which happens asynchronously. It is definitely not available in the Exception handler. You could of course generate a GUID yourself and add that to the message, this will give the same effect and has the added bonus of being searchable in Service Center.

Hé Kilian, thanks for the advice.
About adding that guid ourselves, if you say add that to the message, do I understand it correctly that we should do this :

AllExceptions.ExceptionMessage = AllExceptions.ExceptionMessage + " (code : " + GenerateGuid() + ")"

Does that modification to the ExceptionMessage we apply on OnException get persisted in the error record visible in service center? 


edit : no wait, that does not make any sense :-) perhaps you mean the client action LogMessage? In that case I do understand it and it would indeed be searchable in service center, but that message is not really an Error, right? Is there a LogError action available to achieve this?

mvp_badge
MVP

Hi Gwen,

I was thinking of throwing an exception in code (you'd add it to the Exception Message), but indeed, for exceptions generated by the Platform this isn't possible unfortunately (ExceptionMessage is a read-only property, you cannot assign it).

Hi, yes, we could generate our code while throwing exceptions, but our requirement was to have an identifier code for ALL exceptions, which is why I chose an implementation in our OnException.

Meanwhile, I've implemented a LogMessage client action with a generated code, which is repeated in the end user's "something went wrong" popup message. This allows us to trace the message code in service center, and closely relate the General Log to the real Error Log record by Time of Log, Source and Message, but not really by the code, since, like you mentionned as well, we cannot update ExceptionMessage.


mvp_badge
MVP

Yeah, that's probably the best solution in this case. I'm glad you found a solution that works for you.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.