internal bool WriteCore( Utf8JsonWriter writer, T value, JsonSerializerOptions options, ref WriteStack state) { try { return(TryWrite(writer, value, options, ref state)); } catch (InvalidOperationException ex) when(ex.Source == ThrowHelper.ExceptionSourceValueToRethrowAsJsonException) { ThrowHelper.ReThrowWithPath(state, ex); throw; } catch (JsonException ex) { ThrowHelper.AddJsonExceptionInformation(state, ex); throw; } catch (NotSupportedException ex) { // If the message already contains Path, just re-throw. This could occur in serializer re-entry cases. // To get proper Path semantics in re-entry cases, APIs that take 'state' need to be used. if (ex.Message.Contains(" Path: ")) { throw; } ThrowHelper.ThrowNotSupportedException(state, ex); return(default);