Example #1
0
        /// <summary>
        /// Handles a system error.
        /// </summary>
        /// <param name="error">The error that occurred.</param>
        /// <param name="session">The Alexa session.</param>
        /// <returns>
        /// The <see cref="ResponseBody"/> to return from the skill.
        /// </returns>
        public SkillResponse OnError(SystemExceptionRequest error, Session session)
        {
            Logger.LogError(
                "Failed to handle request for session {SessionId}. Error type {ErrorType} with cause {ErrorCause}: {ErrorMessage}",
                session.SessionId,
                error.Error.Type,
                error.ErrorCause?.requestId,
                error.Error.Message);

            return(SkillResponseBuilder
                   .Tell(Strings.InternalError)
                   .Build());
        }
Example #2
0
        public async Task Cannot_Invoke_Function_With_System_Failure()
        {
            // Arrange
            AlexaFunction function = await CreateFunctionAsync();

            ILambdaContext context = CreateContext();

            var error = new SystemExceptionRequest()
            {
                Error = new Error()
                {
                    Message = "Internal error.",
                    Type    = ErrorType.InternalError,
                },
                ErrorCause = new ErrorCause()
                {
                    requestId = "my-request-id",
                },
            };

            var request = CreateRequest(error);

            // Act
            SkillResponse actual = await function.HandlerAsync(request, context);

            // Assert
            ResponseBody response = AssertResponse(actual);

            response.Card.ShouldBeNull();
            response.Reprompt.ShouldBeNull();

            response.OutputSpeech.ShouldNotBeNull();
            response.OutputSpeech.Type.ShouldBe("SSML");

            var ssml = response.OutputSpeech.ShouldBeOfType <SsmlOutputSpeech>();

            ssml.Ssml.ShouldBe("<speak>Sorry, something went wrong.</speak>");
        }