Пример #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void read(org.neo4j.bolt.messaging.BoltResponseMessageWriter messageWriter) throws java.io.IOException
        public virtual void Read(BoltResponseMessageWriter messageWriter)
        {
            try
            {
                _unpacker.unpackStructHeader();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int signature = (int) unpacker.unpackStructSignature();
                int signature = ( int )_unpacker.unpackStructSignature();
                BoltResponseMessage message = BoltResponseMessage.withSignature(signature);
                try
                {
                    switch (message.innerEnumValue)
                    {
                    case Org.Neo4j.Bolt.v1.messaging.BoltResponseMessage.InnerEnum.SUCCESS:
                        MapValue successMetadata = _unpacker.unpackMap();
                        messageWriter.Write(new SuccessMessage(successMetadata));
                        break;

                    case Org.Neo4j.Bolt.v1.messaging.BoltResponseMessage.InnerEnum.RECORD:
                        long length = _unpacker.unpackListHeader();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.values.AnyValue[] fields = new org.neo4j.values.AnyValue[(int) length];
                        AnyValue[] fields = new AnyValue[( int )length];
                        for (int i = 0; i < length; i++)
                        {
                            fields[i] = _unpacker.unpack();
                        }
                        messageWriter.Write(new RecordMessage(record(fields)));
                        break;

                    case Org.Neo4j.Bolt.v1.messaging.BoltResponseMessage.InnerEnum.IGNORED:
                        messageWriter.Write(IgnoredMessage.IGNORED_MESSAGE);
                        break;

                    case Org.Neo4j.Bolt.v1.messaging.BoltResponseMessage.InnerEnum.FAILURE:
                        MapValue failureMetadata = _unpacker.unpackMap();
                        string   code            = failureMetadata.ContainsKey("code") ? (( StringValue )failureMetadata.Get("code")).stringValue() : Org.Neo4j.Kernel.Api.Exceptions.Status_General.UnknownError.name();
                        string   msg             = failureMetadata.ContainsKey("message") ? (( StringValue )failureMetadata.Get("message")).stringValue() : "<No message supplied>";
                        messageWriter.Write(new FailureMessage(Neo4jError.codeFromString(code), msg));
                        break;

                    default:
                        throw new BoltIOException(Org.Neo4j.Kernel.Api.Exceptions.Status_Request.InvalidFormat, string.Format("Message 0x{0} is not supported.", signature.ToString("x")));
                    }
                }
                catch (System.ArgumentException)
                {
                    throw new BoltIOException(Org.Neo4j.Kernel.Api.Exceptions.Status_Request.InvalidFormat, string.Format("Message 0x{0} is not a valid message signature.", signature.ToString("x")));
                }
            }
            catch (PackStream.PackStreamException e)
            {
                throw new BoltIOException(Org.Neo4j.Kernel.Api.Exceptions.Status_Request.InvalidFormat, string.Format("Unable to read message type. Error was: {0}.", e.Message), e);
            }
        }
Пример #2
0
        /// <summary>
        /// Writes logs about database errors.
        /// Short one-line message is written to both user and internal log.
        /// Large message with stacktrace (if available) is written to internal log.
        /// </summary>
        /// <param name="error"> the error to log. </param>
        /// <seealso cref= StoreLogService </seealso>
        /// <seealso cref= DuplicatingLogProvider </seealso>
        public virtual void Report(Neo4jError error)
        {
            if (error.Status().code().classification() == DatabaseError)
            {
                string message = format("Client triggered an unexpected error [%s]: %s, reference %s.", error.Status().code().serialize(), error.Message(), error.Reference());

                // Writing to user log gets duplicated to the internal log
                _userLog.error(message);

                // If cause/stacktrace is available write it to the internal log
                if (error.Cause() != null)
                {
                    _debugLog.error(message, error.Cause());
                }
            }
        }
Пример #3
0
 public override void MarkFailed(Neo4jError error)
 {
     // this page intentionally left blank
 }