You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@avro.apache.org by Arturo Candela <fr...@gmail.com> on 2017/03/06 16:13:45 UTC

Howto return an method error defined on the json.

Hi guys.

I'm trying to implement the avro rpc 1.7.7 using a rabbitmq queue. I've
more or less a version working and a java client can run remote remote
methods and a c# server is who executes the method and returns the response
to the client.

I'm not able to return an error defined on the protocol, For example, If I
have a mail server with the method send and an error which is called
"ServerError", when I throw that error the server crashes because and
unhandled exception, That is because I don't catch it.

What I would like to know if there is another way to return the exception
to the client or assure that I have a problem in my current implement

Thank you in advance,

Regards

Re: Howto return an method error defined on the json.

Posted by Arturo Candela <fr...@gmail.com>.
Hi again folks.

well, I've used an standard netty server to do one example with the avro
standard code, and I get the same error. I'm using the avro 1.7.7

I've attached the java code and also the json definition, which is based on
the example:
https://github.com/phunt/avro-rpc-quickstart/blob/master/src/main/java/example/Main.java

I get the error AvroRuntimeException but I think that should I get and
AvroRemoteException.

If there is way to get the exception as my Exception not the
avroruntimeexception,

Could you please take a look to the code?

Regards.

El mar., 7 mar. 2017 a las 12:18, Arturo Candela (<fr...@gmail.com>)
escribió:

> Hi Everybody.
>
> I'm getting a problem in the java client, instead of getting the
> AvroRemoteExcetiption, I'm getting an AvroRuntimeException.
>
> In the .net Server rpc part, I launch a ServerError (As defined on the
> json structure) but in the java client, I got an "AvroRuntimeException"
>
> The SpecificRequestor.java path is:
> @Override
>   public Exception readError(Schema writer, Schema reader, Decoder in)
>     throws IOException {
>     Object value = getDatumReader(writer, reader).read(null, in);
>     if (value instanceof Exception)
>       return (Exception)value;
>     return new AvroRuntimeException(value.toString());
>   }
>
> The problem is that result of getDatumReader is a string instead of the
> exception object. Both schemas are "string"
>
> I think the avro framework doesn't know my remote exception but I don't
> know why.
>
> Could you help me please?
>
> Regards.
>
>
>
>
>
> El lun., 6 mar. 2017 a las 17:48, Arturo Candela (<fr...@gmail.com>)
> escribió:
>
> Hi
>
> I've found the problem, it was my fault.
>
> Since Avro uses reflection, the unhandled exceptions by user code are
> threated by the debugger as "code" problems. So, if you disable the debug
> options: "Enable Just My Code" the debuging works.
>
> Regards
>
>
>
> http://stackoverflow.com/questions/2658908/why-is-targetinvocationexception-treated-as-uncaught-by-the-ide
>
> El lun., 6 mar. 2017 a las 17:13, Arturo Candela (<fr...@gmail.com>)
> escribió:
>
> Hi guys.
>
> I'm trying to implement the avro rpc 1.7.7 using a rabbitmq queue. I've
> more or less a version working and a java client can run remote remote
> methods and a c# server is who executes the method and returns the response
> to the client.
>
> I'm not able to return an error defined on the protocol, For example, If I
> have a mail server with the method send and an error which is called
> "ServerError", when I throw that error the server crashes because and
> unhandled exception, That is because I don't catch it.
>
> What I would like to know if there is another way to return the exception
> to the client or assure that I have a problem in my current implement
>
> Thank you in advance,
>
> Regards
>
>

Re: Howto return an method error defined on the json.

Posted by Arturo Candela <fr...@gmail.com>.
Hi Everybody.

I'm getting a problem in the java client, instead of getting the
AvroRemoteExcetiption, I'm getting an AvroRuntimeException.

In the .net Server rpc part, I launch a ServerError (As defined on the json
structure) but in the java client, I got an "AvroRuntimeException"

The SpecificRequestor.java path is:
@Override
  public Exception readError(Schema writer, Schema reader, Decoder in)
    throws IOException {
    Object value = getDatumReader(writer, reader).read(null, in);
    if (value instanceof Exception)
      return (Exception)value;
    return new AvroRuntimeException(value.toString());
  }

The problem is that result of getDatumReader is a string instead of the
exception object. Both schemas are "string"

I think the avro framework doesn't know my remote exception but I don't
know why.

Could you help me please?

Regards.





El lun., 6 mar. 2017 a las 17:48, Arturo Candela (<fr...@gmail.com>)
escribió:

Hi

I've found the problem, it was my fault.

Since Avro uses reflection, the unhandled exceptions by user code are
threated by the debugger as "code" problems. So, if you disable the debug
options: "Enable Just My Code" the debuging works.

Regards


http://stackoverflow.com/questions/2658908/why-is-targetinvocationexception-treated-as-uncaught-by-the-ide

El lun., 6 mar. 2017 a las 17:13, Arturo Candela (<fr...@gmail.com>)
escribió:

Hi guys.

I'm trying to implement the avro rpc 1.7.7 using a rabbitmq queue. I've
more or less a version working and a java client can run remote remote
methods and a c# server is who executes the method and returns the response
to the client.

I'm not able to return an error defined on the protocol, For example, If I
have a mail server with the method send and an error which is called
"ServerError", when I throw that error the server crashes because and
unhandled exception, That is because I don't catch it.

What I would like to know if there is another way to return the exception
to the client or assure that I have a problem in my current implement

Thank you in advance,

Regards

Re: Howto return an method error defined on the json.

Posted by Arturo Candela <fr...@gmail.com>.
Hi

I've found the problem, it was my fault.

Since Avro uses reflection, the unhandled exceptions by user code are
threated by the debugger as "code" problems. So, if you disable the debug
options: "Enable Just My Code" the debuging works.

Regards


http://stackoverflow.com/questions/2658908/why-is-targetinvocationexception-treated-as-uncaught-by-the-ide

El lun., 6 mar. 2017 a las 17:13, Arturo Candela (<fr...@gmail.com>)
escribió:

> Hi guys.
>
> I'm trying to implement the avro rpc 1.7.7 using a rabbitmq queue. I've
> more or less a version working and a java client can run remote remote
> methods and a c# server is who executes the method and returns the response
> to the client.
>
> I'm not able to return an error defined on the protocol, For example, If I
> have a mail server with the method send and an error which is called
> "ServerError", when I throw that error the server crashes because and
> unhandled exception, That is because I don't catch it.
>
> What I would like to know if there is another way to return the exception
> to the client or assure that I have a problem in my current implement
>
> Thank you in advance,
>
> Regards
>