Beispiel #1
0
        /// <summary>
        /// BadRequestエラー応答を生成します。
        /// </summary>
        /// <returns>エラー応答</returns>
        public static ErrorObjectResult BadRequest()
        {
            var result = new ErrorObjectResult(new Error()
            {
                Code    = ErrorCodes.BadRequest,
                Message = ErrorMessages.ErrorResultBadRequest,
            });

            result.StatusCode = StatusCodes.Status400BadRequest;
            return(result);
        }
Beispiel #2
0
        /// <summary>
        /// InternalServerErrorエラー応答を生成します。
        /// </summary>
        /// <returns>エラー応答</returns>
        public static ErrorObjectResult InternalServerError()
        {
            var result = new ErrorObjectResult(new Error()
            {
                Code    = ErrorCodes.InternalServerError,
                Message = ErrorMessages.ErrorResultInternalServerError,
            });

            result.StatusCode = StatusCodes.Status500InternalServerError;
            return(result);
        }
Beispiel #3
0
        /// <summary>
        /// Forbiddenエラー応答を生成します。
        /// </summary>
        /// <returns>エラー応答</returns>
        public static ErrorObjectResult Forbidden()
        {
            var result = new ErrorObjectResult(new Error()
            {
                Code    = ErrorCodes.Forbidden,
                Message = ErrorMessages.ErrorResultForbidden,
            });

            result.StatusCode = StatusCodes.Status403Forbidden;
            return(result);
        }
Beispiel #4
0
        /// <summary>
        /// NotFoundエラー応答を生成します。
        /// </summary>
        /// <returns>エラー応答</returns>
        public static ErrorObjectResult NotFound()
        {
            var result = new ErrorObjectResult(new Error()
            {
                Code    = ErrorCodes.NotFound,
                Message = ErrorMessages.ErrorResultNotFound,
            });

            result.StatusCode = StatusCodes.Status404NotFound;
            return(result);
        }
Beispiel #5
0
        /// <summary>
        /// Unauthorizedエラー応答を生成します。
        /// </summary>
        /// <returns>エラー応答</returns>
        public static ErrorObjectResult Unauthorized()
        {
            var result = new ErrorObjectResult(new Error()
            {
                Code    = ErrorCodes.Unauthorized,
                Message = ErrorMessages.ErrorResultUnauthorized,
            });

            result.StatusCode = StatusCodes.Status401Unauthorized;
            return(result);
        }
Beispiel #6
0
        /// <summary>
        /// InvalidAuthorizationTokenエラー応答を生成します。
        /// </summary>
        /// <returns>エラー応答</returns>
        public static ErrorObjectResult InvalidAuthorizationToken()
        {
            var result = new ErrorObjectResult(new Error()
            {
                Code    = ErrorCodes.InvalidAuthorizationToken,
                Message = ErrorMessages.ErrorResultInvalidAuthorizationToken,
            });

            result.StatusCode = StatusCodes.Status401Unauthorized;
            return(result);
        }
Beispiel #7
0
        /// <summary>
        /// InvalidAuthorizationSchemeエラー応答を生成します。
        /// </summary>
        /// <returns>エラー応答</returns>
        public static ErrorObjectResult InvalidAuthorizationScheme()
        {
            var result = new ErrorObjectResult(new Error()
            {
                Code    = ErrorCodes.InvalidAuthorizationScheme,
                Message = ErrorMessages.ErrorResultInvalidAuthorizationScheme,
            });

            result.StatusCode = StatusCodes.Status400BadRequest;
            return(result);
        }
Beispiel #8
0
        /// <summary>
        /// InvalidGrantTypeエラー応答を生成します。
        /// </summary>
        /// <returns>エラー応答</returns>
        public static ErrorObjectResult InvalidGrantType()
        {
            var result = new ErrorObjectResult(new Error()
            {
                Code    = ErrorCodes.InvalidGrantType,
                Message = ErrorMessages.ErrorResultInvalidGrantType,
            });

            result.StatusCode = StatusCodes.Status400BadRequest;
            return(result);
        }
Beispiel #9
0
        /// <summary>
        /// NoAuthorizationHeaderエラー応答を生成します。
        /// </summary>
        /// <returns>エラー応答</returns>
        public static ErrorObjectResult NoAuthorizationHeader()
        {
            var result = new ErrorObjectResult(new Error()
            {
                Code    = ErrorCodes.NoAuthorizationHeader,
                Message = ErrorMessages.ErrorResultNoAuthorizationHeader,
            });

            result.StatusCode = StatusCodes.Status401Unauthorized;
            return(result);
        }
Beispiel #10
0
        /// <summary>
        /// ValidationErrorエラー応答を生成します。
        /// </summary>
        /// <param name="errors"><see cref="List&lt;Error&gt;"/></param>
        /// <returns>エラー応答</returns>
        public static ErrorObjectResult ValidationError(List <Error> errors)
        {
            var result = new ErrorObjectResult(new Error()
            {
                Code    = ErrorCodes.ValidationError,
                Message = ErrorMessages.ErrorResultValidationError,
                Details = errors,
            });

            result.ContentTypes.Add(MediaTypeNames.Application.Json);
            return(result);
        }