Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8717089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:13:55+00:00 2026-06-13T06:13:55+00:00

So I have modified the todo service that gives me a response. When I

  • 0

So I have modified the todo service that gives me a response.

When I deliberately throw an unhandled error to test ServiceExceptionHandler code below, if I use the default /Backbone.Todos/todo/1?format=json, it is fine.

But if I use /Backbone.Todos/todo/1?format=xml, it says:

XML Parsing Error: not well-formed Location:
/Backbone.Todos/todo/1 Line Number 1, Column 2:

Here is my code:

public class AppHost : AppHostBase {
    public override void Configure(Funq.Container container) {
        //Unhandled errors
        this.ServiceExceptionHandler = (req, ex) => {
            var res = new { //i return a dynamic object here ... and it doesn't work
                Result = null as object,
                ResponseStatus = new ResponseStatus() {
                ErrorCode = "Error",
                Message = "Not available",
                StackTrace = "Not available"
                }
            };
            return res;
        };
    //...
    }
//....
}

//My normal request/response dtos look like this:
//-----------------------------------------
[Route("/todo/{id}", "GET")] //display req
public class GetTodo : IReturn<TodoResponse> {
    public long Id { get; set; }
}
public class TodoResponse : IHasResponseStatus {
    public IList<Todo> Result { get; set; }
    public ResponseStatus ResponseStatus { get; set; }
}

The thing is, when error occured I can’t construct a correct type of response without knowing what type it is. I only get incoming Request and Exception as paramaters, but not Response type.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T06:13:56+00:00Added an answer on June 13, 2026 at 6:13 am

    I suspect the error is because XML cannot automatically serialize dynamic objects in .net.

    I not entirely sure I know what you are trying to do but you could try using the built in utilities to handle the exception then modify it as you want.

    this.ServiceExceptionHandler = (req, ex) =>
    {
        var responseStatus = ex.ToResponseStatus();
        var errorResponse = ServiceStack.ServiceHost.DtoUtils.CreateErrorResponse(req, ex, responseStatus);
        return errorResponse;
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have modified a working Windows service that had always been starting beforehand. After
I have modified my notebook's stylesheet to include a StyleData[Todo] that inherits from StyleData[Item]
I have modified unobtrusive validation script to replace error messages with qtips. To do
Recently I have modified my code to While taking input form STDIN, I moved
I have a Service that downloads a file from the internet. What I want
I have a web service that is processed on the Spring end as follows:
I have an application wherein I have a service class that implements a locationlistener.
I have a simple todo app that where each 'todo' has a title, description,
I have an app which uses a service that is included in the application's
I have modified a slider script to mimic ebay's slider on home page. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.