Skip to content
This repository has been archived by the owner on Dec 18, 2017. It is now read-only.

Also remove stack traces from compilation errors as part of #864 #2853

Closed
wants to merge 3 commits into from

Conversation

JunTaoLuo
Copy link
Contributor

#864 hide stack traces from compilation errors as well

image

if (ex.InnerException is ICompilationException)
// Compilation exceptions either throw FileNotFound or FileLoad exceptions and may change
// from version to version. It's safest to catch both types of exceptions
if (ex is FileLoadException || ex is FileNotFoundException)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not check the InnerException of any exception?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could for compilation exceptions, but historically I've seen us only catching these two types of exceptions. e.g. 196e111.

Alternatively, we can catch FileNotFoundExceptions for ICompilationException and EntryPointNotFoundException then catch generic Exception only for ICompilationExceptions.

@JunTaoLuo
Copy link
Contributor Author

cc @troydai @anurse @davidfowl @moozzyk

applicationName,
ex.InnerException);
}
else
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this else is technically not needed...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted.

@JunTaoLuo JunTaoLuo force-pushed the johluo/864-cleanup-compilation-errors branch from c2533e8 to b949e01 Compare September 28, 2015 20:59
@@ -229,19 +229,24 @@ private Task<int> ExecuteMain(DefaultHost host, string applicationName, string[]
{
assembly = host.GetEntryPoint(applicationName);
}
catch (FileNotFoundException ex) when (new AssemblyName(ex.FileName).Name == applicationName)
catch (Exception ex)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before we threw with ThrowEntryPointNotfoundException only if ex.FileName == applicationName now we will throw for any FileLoadException or FileNotFoundException - is it intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I checked with @davidfowl about it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't you write this as

catch (Exception ex) when (ex is FileLoadException || ex is FileNotFoundException)`
{
    if (ex.InnerException is ICompilationException)
    {
        throw SuppressStackTrace(ex.InnerException);
    }

    ThrowEntryPointNotfoundException(
        host,
        applicationName,
        ex.InnerException);
}

Wouldn't need the other throw.

@JunTaoLuo JunTaoLuo added this to the 1.0.0-beta8 milestone Sep 28, 2015
@JunTaoLuo JunTaoLuo self-assigned this Sep 28, 2015
@davidfowl
Copy link
Member

:shipit:

2 similar comments
@troydai
Copy link
Contributor

troydai commented Sep 28, 2015

:shipit:

@pranavkm
Copy link
Contributor

:shipit:

@JunTaoLuo
Copy link
Contributor Author

merged to dev

@JunTaoLuo JunTaoLuo closed this Sep 28, 2015
@JunTaoLuo JunTaoLuo deleted the johluo/864-cleanup-compilation-errors branch October 1, 2015 21:33
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants