Skip to content

Add inner exception in ConvertExceptionToRuntimeException #338

Description

@kartonka

It would be important for us not to lose the exception information as it travels from our backend to our frontend. After analyzing the code our suggestion would be to adjust the ConvertExceptionToRuntimeException function to add the original exception as an inner exception to WampRpcCanceledException and to WampRpcRuntimeException.

Activity

  1. darkl commented on Sep 3, 2021

    @darkl
    Member
  2. kartonka commented on Sep 3, 2021

    @kartonka
    Author

    I think this would remain backwards compatible:

            protected static WampException ConvertExceptionToRuntimeException(Exception exception)
            {
                if (exception is OperationCanceledException)
                {
                    return new WampRpcCanceledException(null, exception.Message, null, exception.Message, exception);
                }
    
                return new WampRpcRuntimeException(null, exception.Message, null, exception.Message, exception);
            }
    
  3. darkl commented on Sep 3, 2021

    @darkl
    Member
  4. kartonka commented on Sep 3, 2021

    @kartonka
    Author

    Hmm, good point, I see...
    As long as Wamp intends to provide security through such features, it is not possible to support applications that do not need such features (like ours). If Wamp did not want to provide this security but let the application decide to do it for themselves (e.g. through such a try-catch + throw), it could be changed.
    As this decision is not in my hands (maybe not even in yours), I guess we'll have to figure out a workaround but thanks for your time!:)

  5. esso23 commented on Sep 3, 2021

    @esso23

    Not sure what your use case is, but wouldn't it be enough to just have the exception logged on the Callee? (WampSharp supports that)

  6. kartonka commented on Sep 6, 2021

    @kartonka
    Author

    We wanted to have the server layer between our frontend and backend the thinnest possible in our application and avoid implementing a function for every callee with an exception handling. Ideally, our backend functions would solely be called through attributed interfaces.

    Example:

    // Server
    public interface IBackendClass
    {
    	[WampProcedure("com.myapp.method1")]
    	public void Method1(); // throws many types of exceptions
    }
    
    public class BackendClassProxy: BackendClass, IBackendClass
    {
    	// empty!
    }
    
    // an instance of BackendClassProxy is registered via realm.Services.RegisterCallee
    
    // Backend
    public class BackendClass
    {
    	public void Method1()
    	{
    		if (endOfTheWorld())
    		{
    			throw new InvalidOperationException();
    		}
    		else
    		{
    			throw new MyVerySpecialExceptionType();
    		}
    		// ...
    	}
    }
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions