mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Don't crash when main.dart is a 404.
Ideally we would show a failwhale or some such, but I don't know how we would bundle that file with our APK yet. Fixes https://github.com/domokit/mojo/issues/228 R=abarth@chromium.org Review URL: https://codereview.chromium.org/1182633002.
This commit is contained in:
parent
08b0b8b540
commit
c1cad6ccda
@ -119,7 +119,9 @@ void DartController::DidLoadMainLibrary(KURL url) {
|
||||
|
||||
Dart_Handle library = Dart_LookupLibrary(
|
||||
StringToDart(dart_state(), url.string()));
|
||||
CHECK(!LogIfError(library));
|
||||
// TODO(eseidel): We need to load a 404 page instead!
|
||||
if (LogIfError(library))
|
||||
return;
|
||||
DartInvokeAppField(library, ToDart("main"), 0, nullptr);
|
||||
}
|
||||
|
||||
|
||||
@ -239,6 +239,11 @@ void DartLoader::WaitForDependencies(
|
||||
}
|
||||
|
||||
void DartLoader::LoadLibrary(const KURL& url, mojo::URLResponsePtr response) {
|
||||
if (response && response->status_code >= 400) {
|
||||
LOG(ERROR) << url.string().utf8().data()
|
||||
<< " failed with " << response->status_code;
|
||||
}
|
||||
|
||||
const auto& result = pending_libraries_.add(url.string(), nullptr);
|
||||
if (result.isNewEntry) {
|
||||
OwnPtr<Job> job = adoptPtr(new ImportJob(this, url));
|
||||
|
||||
@ -76,9 +76,14 @@ public class UrlLoaderImpl implements UrlLoader {
|
||||
buffer.put(tmp);
|
||||
mProducer.endWriteData(result == -1 ? 0 : result);
|
||||
} catch (MojoException e) {
|
||||
if (e.getMojoResult() != MojoResult.SHOULD_WAIT)
|
||||
// No one read the pipe, they just closed it.
|
||||
if (e.getMojoResult() == MojoResult.FAILED_PRECONDITION) {
|
||||
break;
|
||||
} else if (e.getMojoResult() == MojoResult.SHOULD_WAIT) {
|
||||
mCore.wait(mProducer, Core.HandleSignals.WRITABLE, -1);
|
||||
} else {
|
||||
throw e;
|
||||
mCore.wait(mProducer, Core.HandleSignals.WRITABLE, -1);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "mSource.read failed", e);
|
||||
break;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user