Handle errors while querying notes
This commit is contained in:
parent
c1fabe943c
commit
86ec7f4de8
@ -6,14 +6,15 @@ import java.sql.PreparedStatement
|
|||||||
import java.sql.ResultSet
|
import java.sql.ResultSet
|
||||||
import java.sql.Types
|
import java.sql.Types
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
import java.util.UUID as JavaUUID
|
||||||
|
|
||||||
class UuidBinarySqlType : SqlType<java.util.UUID>(Types.BINARY, typeName = "uuidBinary") {
|
class UuidBinarySqlType : SqlType<JavaUUID>(Types.BINARY, typeName = "uuidBinary") {
|
||||||
override fun doGetResult(rs: ResultSet, index: Int): UUID? {
|
override fun doGetResult(rs: ResultSet, index: Int): JavaUUID? {
|
||||||
val value = rs.getBytes(index) ?: return null
|
val value = rs.getBytes(index) ?: return null
|
||||||
return ByteBuffer.wrap(value).let { b -> UUID(b.long, b.long) }
|
return ByteBuffer.wrap(value).let { b -> JavaUUID(b.long, b.long) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun doSetParameter(ps: PreparedStatement, index: Int, parameter: UUID) {
|
override fun doSetParameter(ps: PreparedStatement, index: Int, parameter: JavaUUID) {
|
||||||
val bytes = ByteBuffer.allocate(16)
|
val bytes = ByteBuffer.allocate(16)
|
||||||
.putLong(parameter.mostSignificantBits)
|
.putLong(parameter.mostSignificantBits)
|
||||||
.putLong(parameter.leastSignificantBits)
|
.putLong(parameter.leastSignificantBits)
|
||||||
@ -22,6 +23,6 @@ class UuidBinarySqlType : SqlType<java.util.UUID>(Types.BINARY, typeName = "uuid
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <E : Any> BaseTable<E>.uuidBinary(name: String): BaseTable<E>.ColumnRegistration<java.util.UUID> {
|
fun <E : Any> BaseTable<E>.uuidBinary(name: String): BaseTable<E>.ColumnRegistration<JavaUUID> {
|
||||||
return registerColumn(name, UuidBinarySqlType())
|
return registerColumn(name, UuidBinarySqlType())
|
||||||
}
|
}
|
||||||
|
|||||||
@ -74,14 +74,22 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async loadNotes() {
|
async loadNotes() {
|
||||||
await this.$axios.get('/notes').then((e) => {
|
await this.$axios
|
||||||
this.notes = e.data
|
.get('/notes')
|
||||||
this.loading = false
|
.then((e) => {
|
||||||
})
|
this.notes = e.data
|
||||||
|
this.loading = false
|
||||||
|
})
|
||||||
|
.catch((_) => {})
|
||||||
},
|
},
|
||||||
editItem(item) {},
|
editItem(item) {},
|
||||||
async deleteItem(item) {
|
async deleteItem(item) {
|
||||||
await this.$axios.delete(`/notes/${item.uuid}`).then(this.loadNotes)
|
try {
|
||||||
|
await this.$axios.delete(`/notes/${item.uuid}`)
|
||||||
|
} catch (_) {
|
||||||
|
} finally {
|
||||||
|
await this.loadNotes()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
format,
|
format,
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user