- let inserted_local_user = match LocalUser::create(context.pool(), &local_user_form).await {
- Ok(lu) => lu,
- Err(e) => {
- let err_type = if e.to_string()
- == "duplicate key value violates unique constraint \"local_user_email_key\""
- {
- "email_already_exists"
- } else {
- "user_already_exists"
- };
-
- // If the local user creation errored, then delete that person
- Person::delete(context.pool(), inserted_person.id).await?;
-
- return Err(LemmyError::from_error_message(e, err_type));
- }
- };