Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Throw FatalError after reporting generic introspection error #812

Closed
wants to merge 2 commits into from
Closed

Throw FatalError after reporting generic introspection error #812

wants to merge 2 commits into from

Conversation

hermanventer
Copy link
Contributor

Instead of throwing peculiarly behaving introspection error completions, we now report all errors via the error handler, using CompilerDiagnostic objects that are just normal host objects. Following a report, we always throw a FatalError.

Eventually all of the places where generic introspection errors are thrown will be replaced by specific errors and may have site specific error recovery logic.

try {
let realmOptions = { serialize: true, compatibility, uniqueSuffix: "" };
let realm = construct_realm(realmOptions);
initializeGlobals(realm);
let serializerOptions = { initializeMoreModules: speculate, delayUnsupportedRequires, internalDebug: true };
let serializer = new Serializer(realm, serializerOptions);
let sources = [{ filePath: name, fileContents: code }];
let serialized = serializer.init(sources, false, onError);
let serialized = serializer.init(sources, false);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think I had introduced the onError parameter to the serializer just for dealing with Introspection errors here. Can the concept be removed in the serializer code if there's no other user for it?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ignore, I saw you already did it!

this.nativeStack = nativeStack || new Error().stack;
}

nativeStack: string;
}
export class IntrospectionThrowCompletion extends ThrowCompletion {
Copy link
Contributor

Choose a reason for hiding this comment

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

Very nice.

let [message, stack] = this.modules.getMessageAndStack(effects);
console.log(`delaying require(${moduleIdValue}): ${message} ${stack}`);
if (result instanceof PossiblyNormalCompletion) {
console.log(`delaying require(${moduleIdValue}`);
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove this line, as we'll output the same message below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah yes, will do.

@@ -97,8 +91,6 @@ class ModuleTracer extends Tracer {
return undefined;
} else {
let result;
let oldErrorHandler = realm.errorHandler;
realm.errorHandler = () => "Fail";
Copy link
Contributor

Choose a reason for hiding this comment

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

By deleting this code, the messages will appear on the screen as errors, not differentiating to our confused users that this is in case recoverable by delaying the require() call?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is indeed a problem. I'll address it today in a followup pull request.

@@ -461,6 +393,9 @@ export class Modules {
if (escapes) return undefined;

return compl;
} catch (err) {
if (err instanceof FatalError) return undefined;
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like you sneaked in an actual bug fix?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It got uncovered by throwing FatalError for all failures and therefore needs fixing here.

Copy link
Contributor

@NTillmann NTillmann left a comment

Choose a reason for hiding this comment

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

It's great to see the unification of error handling!

I hope it'll be easy to collect user-code level stack traces for FatalErrors one day...

@facebook-github-bot
Copy link

@hermanventer has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link

@hermanventer has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@hermanventer hermanventer deleted the introspection branch July 24, 2017 17:04
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.

3 participants