diff --git a/src/YamlValidator/SchemaLoader.cs b/src/YamlValidator/SchemaLoader.cs index 540a4685..85e3e4fc 100644 --- a/src/YamlValidator/SchemaLoader.cs +++ b/src/YamlValidator/SchemaLoader.cs @@ -22,7 +22,7 @@ public JsonSchema Load() var assemblyName = assembly.GetName().Name; if (fileStream == null) { - throw new IOException($"Resource {file} could not found in assembly {assemblyName}"); + throw new YamlValidatorLibraryException($"The schema could not be loaded from assembly."); } using var streamReader = new StreamReader(fileStream); var jsonSchemaString = streamReader.ReadToEnd(); @@ -45,7 +45,7 @@ public JsonSchema Load() } if (node == null) { - throw new InvalidDataException("Schema was not able to be read into memory"); + throw new YamlValidatorLibraryException("The schema could not be serialized from the assembly."); } return node; } diff --git a/src/YamlValidator/ValidatorError.cs b/src/YamlValidator/ValidatorError.cs index 32f9b5ef..f86b370a 100644 --- a/src/YamlValidator/ValidatorError.cs +++ b/src/YamlValidator/ValidatorError.cs @@ -31,9 +31,9 @@ public override string ToString() foreach (var error in Errors) { var errType = string.IsNullOrEmpty(error.Key) ? "Error" : error.Key; - errString += $"\t{errType}: {error.Value}\n"; + errString += $"\t\t- {errType}: {error.Value}\n"; } } - return $"InstanceLocation: {InstanceLocation}\nSchemaPath: {SchemaPath}\nErrors:\n{errString}"; + return $"\t- InstanceLocation: {InstanceLocation}\n\t- SchemaPath: {SchemaPath}\n\t- Errors:\n{errString}"; } } diff --git a/src/YamlValidator/YamlValidatorLibraryException.cs b/src/YamlValidator/YamlValidatorLibraryException.cs new file mode 100644 index 00000000..8638cd95 --- /dev/null +++ b/src/YamlValidator/YamlValidatorLibraryException.cs @@ -0,0 +1,10 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +namespace Microsoft.PowerPlatform.PowerApps.Persistence.YamlValidator; +public class YamlValidatorLibraryException : Exception +{ + public YamlValidatorLibraryException(string reason) : base(message: reason) + { + } +}