예제 #1
0
        private static HttpStatusCode GetHttpStatusCode(DSSException e)
        {
            switch (e.GetType().Name)
            {
            case "UnsupportedLanguageException": return(HttpStatusCode.BadRequest);

            case "UnrecognizedTraitCriterionException": return(HttpStatusCode.BadRequest);

            case "UnrecognizedScopingEntityException": return(HttpStatusCode.BadRequest);

            case "UnrecognizedScopedEntityException": return(HttpStatusCode.BadRequest);

            case "UnrecognizedLanguageException": return(HttpStatusCode.BadRequest);

            case "RequiredDataNotProvidedException": return(HttpStatusCode.BadRequest);

            case "InvalidTimeZoneOffsetException": return(HttpStatusCode.BadRequest);

            case "InvalidDataFormatException": return(HttpStatusCode.BadRequest);

            case "InvalidTraitCriterionDataFormatException": return(HttpStatusCode.BadRequest);

            case "InvalidDriDataFormatException": return(HttpStatusCode.BadRequest);

            case "EvaluationException": return(HttpStatusCode.InternalServerError);

            case "DSSRuntimeException": return(HttpStatusCode.InternalServerError);

            default: return(HttpStatusCode.InternalServerError);
            }
        }
예제 #2
0
        public static string SerializeToString(this DSSException e)
        {
            var serializer = new XmlSerializer(e.GetType());

            var sb = new StringBuilder();

            using (var writer = new StringWriter(sb))
            {
                serializer.Serialize(writer, e);
            }

            return(sb.ToString());
        }