HandleException() 공개 메소드

public HandleException ( Exception exception ) : CompoundDocument
exception System.Exception
리턴 CompoundDocument
예제 #1
0
        public CompoundDocument Transform(object objectGraph, Context context)
        {
            Type innerObjectType = TransformationHelper.GetObjectType(objectGraph);

            if (objectGraph is HttpError)
            {
                return(TransformationHelper.HandleHttpError(objectGraph as HttpError));
            }

            if (objectGraph is Exception)
            {
                return(TransformationHelper.HandleException(objectGraph as Exception));
            }

            TransformationHelper.VerifyTypeSupport(innerObjectType);
            TransformationHelper.AssureAllMappingsRegistered(innerObjectType, context.Configuration);

            var result = new CompoundDocument
            {
                Meta = TransformationHelper.GetMetadata(objectGraph)
            };

            var resource        = TransformationHelper.UnwrapResourceObject(objectGraph);
            var resourceMapping = context.Configuration.GetMapping(innerObjectType);

            var resourceList       = TransformationHelper.UnifyObjectsToList(resource);
            var representationList = resourceList.Select(o => TransformationHelper.CreateResourceRepresentation(o, resourceMapping, context));
            var primaryResource    = TransformationHelper.ChooseProperResourceRepresentation(resource, representationList);

            result.Data = primaryResource;

            if (resourceMapping.Relationships.Any())
            {
                result.Included = TransformationHelper.CreateIncludedRepresentations(resourceList, resourceMapping, context);
            }

            return(result);
        }
예제 #2
0
 public CompoundDocument Transform(Exception error)
 {
     return(TransformationHelper.HandleException(error));
 }