Howto try/catch: CreateSound failed to complete

You can talk about ManiaScript for ManiaPlanet here

Moderator: English Moderator

Post Reply
User avatar
undef.de
Posts: 2095
Joined: 06 Apr 2011, 21:57
Location: Germany, North Sea Coast
Contact:

Howto try/catch: CreateSound failed to complete

Post by undef.de »

Is there something i can do to catch such errors when the connection to the remote resource failed?
Image
Developer of UASECO, a controller with support of the Modescript Gamemodes for TM².
Visit the official website for more: UASECO.org


Developer of various plugins for XAseco/XAseco2 and MPAseco, visit my lab: www.undef.name

You like what I do? Then award a ManiaStar.
kastun
Posts: 18
Joined: 28 Oct 2012, 10:05

Re: Howto try/catch: CreateSound failed to complete

Post by kastun »

You can check if the link exists before creating.

See CHttpManager.

My testing script (seems some bugs mentioned in the linked topic are fixed now):

Code: Select all

<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<manialink version="1">
	<script><!--
		main() { 

		declare CMlLabel MlResult;
		declare Text Link;

		MlResult = (Page.GetFirstChild("MlResult") as CMlLabel);

		Link = "https://forum.maniaplanet.com/index.php";

		MlResult.SetText("Checking link: " ^ Link);

		if (Http.SlotsAvailable > 0) {
			MlResult.SetText(MlResult.Value ^ " \nWe have free http slots (" ^ Http.SlotsAvailable ^ ").");
			if (Http.IsValidUrl(Link)) {
				MlResult.SetText(MlResult.Value ^ " \nLink is valid.");

				declare Request <=> Http.CreateGet(Link) ;
				wait(Request.IsCompleted);

				if (Request.StatusCode == 200) {
					MlResult.SetText(MlResult.Value ^ " \nLink is available :)");
				} else {
					MlResult.SetText(MlResult.Value ^ " \nLink unavailable :(");
				}

				Http.Destroy(Request);
				Request = Null;             
			} else {
					MlResult.SetText(MlResult.Value ^ " \nLink is not valid!");
			}
		} else {
			MlResult.SetText(MlResult.Value ^ " \nNo free http slots!");
		}
	}
	--></script>
	<timeout>0</timeout>
	<label id="MlResult" posn="-95 10 3" sizen="170 10" halign="top" valign="left" text="History:" autonewline="1" />
</manialink>
Post Reply

Return to “ManiaScript”

Who is online

Users browsing this forum: No registered users and 1 guest