add some safety handling
This commit is contained in:
Родитель
fc5b997c51
Коммит
93eeb1b43e
|
@ -16,6 +16,7 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
using Steeltoe.Tooling.Models;
|
using Steeltoe.Tooling.Models;
|
||||||
using YamlDotNet.RepresentationModel;
|
using YamlDotNet.RepresentationModel;
|
||||||
|
|
||||||
|
@ -37,6 +38,11 @@ namespace Steeltoe.Tooling.Helpers
|
||||||
/// <returns>project model</returns>
|
/// <returns>project model</returns>
|
||||||
public Project BuildProject(string projectFile)
|
public Project BuildProject(string projectFile)
|
||||||
{
|
{
|
||||||
|
if (!File.Exists(projectFile))
|
||||||
|
{
|
||||||
|
throw new ToolingException($"project file not found: {projectFile}");
|
||||||
|
}
|
||||||
|
|
||||||
var project = new Project
|
var project = new Project
|
||||||
{
|
{
|
||||||
Name = Path.GetFileNameWithoutExtension(projectFile),
|
Name = Path.GetFileNameWithoutExtension(projectFile),
|
||||||
|
@ -50,6 +56,11 @@ namespace Steeltoe.Tooling.Helpers
|
||||||
{
|
{
|
||||||
var launchSettingsPath =
|
var launchSettingsPath =
|
||||||
Path.Join(Path.GetDirectoryName(projectFile), "Properties", "launchSettings.json");
|
Path.Join(Path.GetDirectoryName(projectFile), "Properties", "launchSettings.json");
|
||||||
|
if (!File.Exists(launchSettingsPath))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
var yaml = new YamlStream();
|
var yaml = new YamlStream();
|
||||||
using (var reader = new StreamReader(launchSettingsPath))
|
using (var reader = new StreamReader(launchSettingsPath))
|
||||||
{
|
{
|
||||||
|
|
Загрузка…
Ссылка в новой задаче