이것은 매우 간단한 질문이며, 나를 귀찮게하는 자신의 newb 상태입니다. 사과.Try-Catch는 사용자 정의 예외 유형을 catch하지 않습니다.
왜이 코드가 작동하지 않습니까?
if ((!substr_count($response, "200 Account created successfully") > 0)) // If failed
{
if ((substr_count($response, "400 EmailAddressInUse") > 0)) // If email address already in use
{
throw new emailInUseException($response);
}
throw new exception("Error: Could not create account. Reason: $response");
}
emailInUse
캐치 :(작동하지 않는 것 create_account
함수 내에서
try
{
create_account($accountXML);
echo "<p>Successfully created your account.</p>";
try
{
create_page($pageXML,$base64_credentials);
echo "<p>Successfully created your page!</p>";
}
catch (exception $e){ echo "<p>$e</p>"; }
}
catch(exception $e)
{
echo "<p>$e</p>";
}
catch(emailInUseException $e)
{
echo "<p>Error: Email already in use. Could not create account.</p>";
}
...
업데이트 : 디버깅 나는 다음과 같은 오류가 활성화 : Fatal error: Class 'emailInUseException' not found
정말 끔찍한 일입니다. 감사합니다. 어떤 도움.
무엇이'emailInUse' 함수에 있습니까? – Neal
@Neal :'emailInUse'는 커스텀 예외 타입으로 보입니다. 아마 더 나은'EmailInUseException'라는 이름이지만 누가 판단 할 사람이 있을까요? – AgentConundrum
@Agent 나는 그것을 할 것이다! –