Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do no support throw exception inside method call #18

Open
weilitao opened this issue Jun 22, 2016 · 4 comments
Open

Do no support throw exception inside method call #18

weilitao opened this issue Jun 22, 2016 · 4 comments

Comments

@weilitao
Copy link

Hi,

When I throw an exception in Meteor method, like that:
throw new Meteor.Error('abcdef');

in Meteor-Unity side, an exception occurred below:

System.ComponentModel.BaseNumberConverter.ConvertFrom (ITypeDescriptorContext context, System.Globalization.CultureInfo culture, System.Object value)
System.ComponentModel.TypeConverter.ConvertFrom (System.Object o)
JsonFx.Json.TypeCoercionUtility.CoerceType (System.Type targetType, System.Object value) (at Assets/Meteor-Unity/JsonFx/TypeCoercionUtility.cs:383)
JsonFx.Json.JsonReader.ReadString (System.Type expectedType) (at Assets/Meteor-Unity/JsonFx/JsonReader.cs:779)
JsonFx.Json.JsonReader.Read (System.Type expectedType, Boolean typeIsHint) (at Assets/Meteor-Unity/JsonFx/JsonReader.cs:312)
JsonFx.Json.JsonReader.ReadObject (System.Type objectType) (at Assets/Meteor-Unity/JsonFx/JsonReader.cs:477)
JsonFx.Json.JsonReader.Read (System.Type expectedType, Boolean typeIsHint) (at Assets/Meteor-Unity/JsonFx/JsonReader.cs:304)
JsonFx.Json.JsonReader.ReadObject (System.Type objectType) (at Assets/Meteor-Unity/JsonFx/JsonReader.cs:477)
JsonFx.Json.JsonReader.Read (System.Type expectedType, Boolean typeIsHint) (at Assets/Meteor-Unity/JsonFx/JsonReader.cs:304)
JsonFx.Json.JsonReader.Deserialize (Int32 start, System.Type type) (at Assets/Meteor-Unity/JsonFx/JsonReader.cs:275)
JsonFx.Json.JsonReader.Deserialize (System.String value, Int32 start, System.Type type) (at Assets/Meteor-Unity/JsonFx/JsonReader.cs:1005)
JsonFx.Json.JsonReader.Deserialize[ResultMessage] (System.String value) (at Assets/Meteor-Unity/JsonFx/JsonReader.cs:959)
Meteor.Extensions.StringExtensions.Deserialize[ResultMessage] (System.String data) (at Assets/Meteor-Unity/Extensions/StringExtensions.cs:13)
Meteor.Internal.LiveData.HandleOnTextMessageRecv (System.String socketMessage) (at Assets/Meteor-Unity/LiveData/LiveData.cs:389)
Meteor.Internal.LiveData+<Dispatcher>c__Iterator7.MoveNext () (at Assets/Meteor-Unity/LiveData/LiveData.cs:205)

So how to support catch exception during method call?

@doctorpangloss
Copy link
Member

Could you show me some more code to help me reproduce the issue?

@weilitao
Copy link
Author

weilitao commented Jun 23, 2016

Hi, below is code sample:

Meteor side:

export const play = new ValidatedMethod({
  name: 'sample',
  validate: null,
  run() {
    throw new Meteor.Error('test');
  },
});

Meteor-Unity side:

// Create a method call that returns a string
var methodCall = Meteor.Method<SampleResponse>.Call ("sample");

// Execute the method. This will yield until all the database side effects have synced.
yield return (Coroutine)methodCall;

if (methodCall.Error != null) {
  var response = methodCall.Response;
  Debug.Log(string.Format("Method response:\n{0}", JsonWriter.Serialize(response)));
} else {
  Debug.Log(methodCall.Error);

And if I turn on log Meteor.Connection.Logging = true;, log from DDP shows:

{"msg":"result","id":"sample-1","error":{"error":"test","message":"[test]","errorType":"Meteor.Error"}}
UnityEngine.Debug:Log(Object)

@doctorpangloss
Copy link
Member

Thanks for the additional code, I will fix this issue.

@weilitao
Copy link
Author

weilitao commented Jul 6, 2016

Thanks, do you have any plan when the bug would be fixed :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants