/// <summary>Handles the exception.</summary> /// <param name="context">The context.</param> /// <param name="exception">The exception.</param> /// <returns></returns> internal static int HandleException(this ApiRequestContext context, Exception exception) { int code; if (exception is ApiException apiException) { code = apiException.HttpStatus; } else { code = 500; } if (context != null) { context.AddException(exception); } return(code); }