wunderDB Error wdbErrors is currently constant, and error messages do not have the ability to show which field/entity/etc caused the error. For example, for Database Missing error (parent db for collection does not exist), the error is
DatabaseDoesNotExistsError = WdbError{
ErrCode: "databaseMissing",
ErrMessage: "database with ID doesn't exist",
HttpStatusCode: 404,
}
Here ErrMessage is constant/fixed and does not include the id which might not exists. This can be modified to make the message as a format and adding the required ID at the caller level so that the message comes as database with ID [databaseId] doesn't exist.
Possible Fixes/Solutions
The error message can be made into a string format (wherever required, and just plain string wherever not required), eg:
DatabaseDoesNotExistsError = WdbError{
ErrCode: "databaseMissing",
ErrMessage: "database with ID [%s] does not exist",
HttpStatusCode: 404,
}
Adding a Format(args) method on the wdbError struct to fill in the placeholders (%s / %i / %v) with the required value. Example
wunderDB Error
wdbErrors
is currently constant, and error messages do not have the ability to show which field/entity/etc caused the error. For example, for Database Missing error (parent db for collection does not exist), the error isHere
ErrMessage
is constant/fixed and does not include the id which might not exists. This can be modified to make the message as a format and adding the required ID at the caller level so that the message comes asdatabase with ID [databaseId] doesn't exist
.Possible Fixes/Solutions
The error message can be made into a string format (wherever required, and just plain string wherever not required), eg:
Adding a
Format(args)
method on thewdbError
struct to fill in the placeholders (%s
/%i
/%v
) with the required value. ExampleAnd at caller end
The function name
Format
can be different to much more specific likeFill
or TBD