The specific message is omitted in production builds
Answered
Barbary Lion posted this in #help-forum
Barbary LionOP
Hello,
I have a question about Server Actions.
I'm currently upgrading my Nextjs application from the page router to the app router, i switched from the "/api/..." aproach to server-actions.
Currently in the API when something wents wrong on the database call I throw an error with a custom message.
Example: User wants to log in and uses wrong password -> throw an Error with the message "Wrong cridentials used" -> User sees a toast with the error message.
When i do this now in the server-actions like this
"use server";
import {createClient} from "@/app/supabase/server"
export async function Login(formData) {
const supabase = createClient();
data = {
email: formData.email,
password: formData.password
};
const {response, error} = await supabase.auth.signInWithPassword(data);
if (error) {
throw new Error("Wrong cridentials used");
}
return {response: {"Sucessfully loged in"}};
}
And it throws an error, I get following message: "Uncaught (in promise) Error: An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error.".
But how can i get the message I provided?
I have a question about Server Actions.
I'm currently upgrading my Nextjs application from the page router to the app router, i switched from the "/api/..." aproach to server-actions.
Currently in the API when something wents wrong on the database call I throw an error with a custom message.
Example: User wants to log in and uses wrong password -> throw an Error with the message "Wrong cridentials used" -> User sees a toast with the error message.
When i do this now in the server-actions like this
"use server";
import {createClient} from "@/app/supabase/server"
export async function Login(formData) {
const supabase = createClient();
data = {
email: formData.email,
password: formData.password
};
const {response, error} = await supabase.auth.signInWithPassword(data);
if (error) {
throw new Error("Wrong cridentials used");
}
return {response: {"Sucessfully loged in"}};
}
And it throws an error, I get following message: "Uncaught (in promise) Error: An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error.".
But how can i get the message I provided?
5 Replies
if (error) {
return { error: "Wrong cridentials used" };
}Barbary LionOP
How can I handle it at the client-component so that the request actually gets set as a failed request?
use
useFormState or useState hookAnswer