2012年3月24日土曜日

Returning Exceptions

Hi

Using the example:
http://atlas.asp.net/quickstart/atlas/doc/services/default.aspx#catchingExceptions

Both IE and FF throw javascript errors

FF: result has no properties
IE: 'null' is null or not an object - 'null' being the result argument from the OnError callback method

See for youself:
http://atlas.asp.net/quickstart/atlas/samples/services/ExceptionPage.aspx

Is this a bug with the Jan06 release? What is the best way around this?

Craig

I just downloaded the Jan06 release and I'm experiencing the same problem...


Hi people,

i'm using January release also, when i run the example from the Atlas quickstart site, i got the same exceptions.

But if i try the example locally (copy the examples to my computer Atlas site), they are working well.

I think the Atlas site is using an older release.

So, Atlas team please, update the quickstart samples site. It's very important for the people who are starting with Atlas have confidence about the samples

This way it's much harder to find the errors.


Actually, I can reproduce the problem running the example locally. In my scenerio, I use an ASPX page to host the web method as follows:

MyPage.aspx.cs
[WebMethod]
public void GetData() {
throw new ArgumentException("throw exception");
}

MyPage.aspx
<scriptlanguage="javascript"type="text/javascript">
functionCallServer() {
PageMethods.GetData(,OnComplete, OnTimeout, OnError);
}

function OnComplete() {
alert("Complete");
}

function OnTimeout(result) {
alert(result);
}

function OnError(result) {
alert(result);
}
</script>

<!-- Call the server from a HTML button -->
<inputtype="button"value="Call Server"onclick="CallServer();"/>


you're right,

If i move the method to the same page, i got a null argument in the error delegate.

I tried to add

<atlas:ScriptManagerID="scriptManager"runat="server"EnablePartialRendering="true"

OnPageError="OnScriptManagerPageError">

<ErrorTemplate>

Ha ocurrido un error al procesar esta acción.<br/>

<spanid="errorMessageLabel"></span>

<hr/>

<buttonid="okButton"type="button">

OK</button>

</ErrorTemplate>

</atlas:ScriptManager>

and the server script

<scripttype="text/C#"runat="server">

[WebMethod]

publicvoid ExceptionTest(String someParam)

{

thrownewInvalidOperationException("foo");

}

protectedvoid OnScriptManagerPageError(object sender,PageErrorEventArgs e)

{

// Set e.ErrorMessage to something you want to send down to the client

e.ErrorMessage = (String.IsNullOrEmpty(e.Error.InnerException.Message)) ? e.Error.Message : e.Error.InnerException.Message;

}

</script>

as i have seen at

http://www.nikhilk.net/AtlasM1Refresh.aspx

and the server function OnScriptManagerError is not called, even i checked with fiddler that the server response code is 500.

I'd like to know how to use the new feature of page error handling


Same problem here.
I'm executing a WebMethod and the error handling are returning a null value.

Somone knows how to catch error returned from the WebMethod?

It's a bug in Jan06?


hello guys.

well, i may be wrong since i've only started lookig at atlas today and i've also got this bug while throwing exceptions from web methods defined on the page. after trying to do some debugging, it looks like the problem is on Web.Net.WebResponse.get_objectmethod. the problem is that it gets the result and tries to deserialize it. however, when a method on a page throws an error, the result that is received on the client part is an html page which de JSON can't deserialize. this seems like a bug on the scriptmanager (is this the component that handles server side processing when one calls methods on a page? - ehy, don't forget that i just started today on this :) )
Hi,

we can distinguish 3 cases:

1) The Exception is raised in a method defined in a WebService.
In this case, an instance of the class Web.Net.MethodRequestError issent to the client. This object exposes three properties that give infoon the particular Exception raised: get_message(), get_stackTrace(),get_exceptionType().

2) The Exception is raised during an asynchronous postback.
This means we have declared at least one UpdatePanel. The Exception canbe raised, for example, in an event handler during the Page lifecycle.
In this case, the ScriptManager is able to send the error message downto the client and to display it using its <ErrorTemplate />.Moreover, the server can format the message to be sent to the client byhandling the PageError event of the ScriptManager.

3) The Exception is raised when calling a [WebMethod] defined in a Page.
In this case, no exception handling is performed by the Atlasframework, and the client receives (in the response) the tipical HTMLpage that is displayed on ASP.NET pages when an Exception is raised.

At this point, the the error callback could be declared in this way:

function onError(objError, response) {
if(objError) {
// Got a MethodRequestError instance.
}
else {
// Custom error handling.
alert(response.get_statusCode());
}
}

While the objError parameter is null, the second parameter is theresponse object and we can use it to display, for example, an alertwith the HTTP status code (obviously, while waiting for an improved exception handling in the next release).
hello.

yes, i got into that conclusion after debugging the atlas script file...i think that it should be fixed before the final release...

0 件のコメント:

コメントを投稿