diff --git a/neo4j/error.go b/neo4j/error.go index 4a312557..ef38d582 100644 --- a/neo4j/error.go +++ b/neo4j/error.go @@ -108,6 +108,10 @@ func newDriverError(format string, args ...interface{}) gobolt.GenericError { return &driverError{message: fmt.Sprintf(format, args...)} } +func newSessionExpiredError(format string, args ...interface{}) error { + return &sessionExpiredError{message: fmt.Sprintf(format, args...)} +} + func newDatabaseError(classification, code, message string) gobolt.DatabaseError { return &databaseError{code: code, message: message, classification: classification} } diff --git a/neo4j/runner.go b/neo4j/runner.go index c7590c06..a5aab08a 100644 --- a/neo4j/runner.go +++ b/neo4j/runner.go @@ -144,8 +144,12 @@ func handleRecordsPhase(runner *statementRunner, activeResult *neoResult) error } func transformError(runner *statementRunner, err error) error { - if gobolt.IsWriteError(err) && runner.accessMode == AccessModeRead { - return &sessionExpiredError{"write queries cannot be performed in read access mode"} + if gobolt.IsWriteError(err) { + if runner.accessMode == AccessModeRead { + return newDriverError("write queries cannot be performed in read access mode") + } + + return newSessionExpiredError("server at %s no longer accepts writes", runner.connection.RemoteAddress()) } return err diff --git a/neo4j/test-integration/values_unsupported_test.go b/neo4j/test-integration/values_unsupported_test.go index 9b3cd843..d01f0d0a 100644 --- a/neo4j/test-integration/values_unsupported_test.go +++ b/neo4j/test-integration/values_unsupported_test.go @@ -73,7 +73,7 @@ var _ = Describe("Unsupported Types [V1]", func() { testSend := func(data interface{}) { result, err = session.Run("WITH $x RETURN 1", map[string]interface{}{"x": data}) Expect(err).To(BeConnectorErrorWithCode(0x501)) - Expect(err).To(BeConnectorErrorWithDescription("unable to generate RUN message")) + Expect(err).To(BeConnectorErrorWithDescription("unable to generate run message")) } Context("Send", func() {