fix: make sure all logged errors are preceeded with a message
Just logging an error makes it difficult to relate the error log to code in the codebase. Error logging a message right before the error itself makes it easier to search the codebase for that error log.
This commit is contained in:
@@ -31,6 +31,7 @@ export async function editProfile(_prevState: State, values: FormData) {
|
||||
status: Status.success,
|
||||
}
|
||||
} else {
|
||||
console.error("Error parsing edit profile")
|
||||
console.error(parsedData.error)
|
||||
return {
|
||||
message: "Invalid data, parse failed!",
|
||||
@@ -39,6 +40,9 @@ export async function editProfile(_prevState: State, values: FormData) {
|
||||
}
|
||||
} catch (error) {
|
||||
if (error instanceof ZodError) {
|
||||
console.error(`ZodError handling profile edit`)
|
||||
console.error(error)
|
||||
|
||||
return {
|
||||
errors: error.issues.map((issue) => ({
|
||||
message: `Server validation: ${issue.message}`,
|
||||
@@ -49,7 +53,7 @@ export async function editProfile(_prevState: State, values: FormData) {
|
||||
}
|
||||
}
|
||||
|
||||
console.info(`EditProfile Server Action Error`)
|
||||
console.error(`EditProfile Server Action Error`)
|
||||
console.error(error)
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user