Skip to content

Roslyn analyzer to detect catching DotvvmInterruptRequestExecutionException #1964

@tomasherceg

Description

@tomasherceg

A couple of users were dealing with this unintuitive behavior - when they perform a redirect or returning a file, they wrap it in a try/catch block, and catch all exceptions. However, DotVVM throws DotvvmInterruptRequestExecutionException which needs to be rethrown.

public async Task OnDownloadFile()
{
  try
  {
     ...
     await Context.ReturnFileAsync(bytes, "file.csv", "application/octet-stream");
  }
  catch (System.Exception ex)
  {
    ...
  }
}

We already have Roslyn analyzers in the project. We should detect this pattern when ReturnFile* or Redirect* is called on IDotvvmRequestContext, and if it is inside try/catch block, ensure there is a special case for DotvvmInterruptRequestExecutionException where the exception is rethrown as such:

  catch (DotvvmInterruptRequestExecutionException) 
  {
    throw;
  }

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions