I tested with this script:
PHP:
print( "Start testing." );
try
{
abort( "Aborting now" );
}
finally
{
print( "Let's see if the rest of the script will execute now." );
}
print( "You can continue, the abort has been trapped!" );
This resulted in:
Code:
> call test.ash
Start testing.
[COLOR="#ff0000"]Aborting now[/COLOR]
Let's see if the rest of the script will execute now.
The try...finally structure wasn't added to capture aborts, only to allow you to execute some more instructions in case of an abort.
However, doing this worked:
PHP:
void abort_trap()
{
try
{
abort( "Aborting now" );
}
finally
{
print( "Let's see if the rest of the script will execute now." );
return;
}
return;
}
void main()
{
print( "Start testing." );
abort_trap();
print( "You can continue, the abort has been trapped!" );
}
Code:
> call test.ash
Start testing.
[COLOR="#ff0000"]Aborting now[/COLOR]
Let's see if the rest of the script will execute now.
You can continue, the abort has been trapped!
I guess you could place your visit_url() calls into a special abort trapping function, like this:
PHP:
string safe_visit_url( string url )
{
string response;
try
{
response = visit_url( url );
}
finally
{
return response;
}
return response;
}
I can't find any url that will give me a blank page right now, so I can't test this, but it should work I guess.
EDIT: I tried with "canadia.php" (I'm muscle sign). It works!
PHP:
string safe_visit_url( string url )
{
string response;
try
{
response = visit_url( url );
}
finally
{
return response;
}
return response;
}
void main()
{
print( "Start testing." );
//string res = visit_url( "canadia.php" );
string res = safe_visit_url( "canadia.php" );
print( "You can continue, the abort has been trapped!" );
}
With a simple visit_url():
Code:
> call test.ash
Start testing.
[COLOR="#ff0000"]Server www2.kingdomofloathing.com returned a blank page from canadia.php. Complain to Jick, not us.[/COLOR]
With safe_visit_url():
Code:
> call test.ash
Start testing.
[COLOR="#ff0000"]Server www2.kingdomofloathing.com returned a blank page from canadia.php. Complain to Jick, not us.[/COLOR]
You can continue, the abort has been trapped!