Hello, I am trying to fetch the error codes from supabase on signup with a custom action. I want the custom action below to return "false" when an email is already registered. I can catch a message with AuthException and the code below works.
// Automatic FlutterFlow imports
import '/backend/supabase/supabase.dart';
import '/flutter_flow/flutter_flow_theme.dart';
import '/flutter_flow/flutter_flow_util.dart';
import '/custom_code/actions/index.dart'; // Imports other custom actions
import '/flutter_flow/custom_functions.dart'; // Imports custom functions
import 'package:flutter/material.dart';
// Begin custom action code
// DO NOT REMOVE OR MODIFY THE CODE ABOVE!
import 'package:supabase_flutter/supabase_flutter.dart';
Future<bool> mailcheck(
String email,
String password,
) async {
// Add your function code here!
final supabase = SupaFlow.client;
try {
final response = await supabase.auth.signUp(
email: email,
password: password,
);
// Return `true` if the user is successfully created
return response.user != null;
} on AuthException catch (e) {
// Check for the specific error code
if (e.message == 'User already registered') {
return false; // Email is already registered
} else {
return true; // For other Auth API errors
}
} catch (e) {
// Handle any other unexpected errors
return true;
}
return true;
}
However when I try to use AuthApiException (which I need for more detailed messages) instead of AuthException I get this error message when the custom action goes through a check:
The name 'AuthApiException' isn't a type and can't be used in an on-catch clause. Try correcting the name to match an existing class.
Anyone has an idea why AuthApiException doesn't work? Should be a child of AuthException and behave the same, right?