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

Add inner exception in ConvertExceptionToRuntimeException #338

Open
kartonka opened this issue Sep 3, 2021 · 6 comments
Open

Add inner exception in ConvertExceptionToRuntimeException #338

kartonka opened this issue Sep 3, 2021 · 6 comments

Comments

@kartonka
Copy link

kartonka commented Sep 3, 2021

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.

@darkl
Copy link
Member

darkl commented Sep 3, 2021 via email

@kartonka
Copy link
Author

kartonka commented Sep 3, 2021

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);
        }

@darkl
Copy link
Member

darkl commented Sep 3, 2021 via email

@kartonka
Copy link
Author

kartonka commented Sep 3, 2021

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!:)

@esso23
Copy link

esso23 commented Sep 3, 2021

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)

@kartonka
Copy link
Author

kartonka commented Sep 6, 2021

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants