anchor.diff:        await pkgDir.rename(pkgPath);
   
         // resolve dependencies
  -      await pubEnv.runUpgrade(pkgPath, /* isFlutter */ false);
  +      await _resolveDependencies(pubEnv, task, pkgPath);
   
         await _generateDocs(task, pkgPath, outputDir);
  -
  -      await _writeMetadata(task, pkgPath);
   
         // TODO: upload doc/api to the appropriate bucket
       } finally {
         await tempDir.delete(recursive: true);
       }
       return false; // no race detection
  +  }
  +
  +  Future _resolveDependencies(
  +      PubEnvironment pubEnv, Task task, String pkgPath) async {
  +    final pr = await pubEnv.runUpgrade(pkgPath, /* isFlutter */ false);
  +    if (pr.exitCode != 0) {
  +      _logger.severe('Error while running pub upgrade for $task.\n'
  +          'exitCode: ${pr.exitCode}\n'
  +          'stdout: ${pr.stdout}\n'
  +          'stderr: ${pr.stderr}\n');
  +      throw new Exception('pub upgrade failed with code ${pr.exitCode}');
  +    }
     }
   
     Future _generateDocs(Task task, String pkgPath, String outputDir) async {
  
positive.code:           'stderr: ${pr.stderr}\n');
        throw new Exception('dartdoc execution failed with code ${pr.exitCode}');
      }
    }
  
    Future _writeMetadata(Task task, String pkgPath) async {
      await new File(p.join(pkgPath, metadataFilePath))
          .writeAsString(JSON.encode({
        'package': task.package,
        'version': task.version,
        'dartdoc': await _getDartdocVersion(),
        'timestamp': new DateTime.now().toUtc().toIso8601String(),
      }));
    }
  
    Future<String> _getDartdocVersion() async {
  
negative.code:       throw new Exception('dartdoc execution failed with code ${pr.exitCode}');
      }
  
      final match = _versionRegExp.firstMatch(pr.stdout.toString().trim());
      if (match == null) {
        _logger.severe('Unable to parse dartdoc version: ${pr.stdout}');
        throw new Exception('Unable to parse dartdoc version: ${pr.stdout}');
  