protected bool IsErrorHandled(object currentObject, JsonContract contract, object keyValue, IJsonLineInfo lineInfo, string path, Exception ex) { ErrorContext errorContext = GetErrorContext(currentObject, keyValue, path, ex); if (TraceWriter != null && TraceWriter.LevelFilter >= TraceLevel.Error && !errorContext.Traced) { // only write error once errorContext.Traced = true; string message = (_serializing) ? "Error serializing" : "Error deserializing"; if (contract != null) { message += " " + contract.UnderlyingType; } message += ". " + ex.Message; // add line information to non-json.net exception message if (!(ex is JsonException)) { message = JsonPosition.FormatMessage(lineInfo, path, message); } TraceWriter.Trace(TraceLevel.Error, message, ex); } // attribute method is non-static so don't invoke if no object if (contract != null && currentObject != null) { contract.InvokeOnError(currentObject, Serializer.Context, errorContext); } if (!errorContext.Handled) { Serializer.OnError(new ErrorEventArgs(currentObject, errorContext)); } return(errorContext.Handled); }