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

  • SEARCH
  • Home
  • 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 7129407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T11:14:22+00:00 2026-05-28T11:14:22+00:00

We have a restlet server and client. We need to pass the error status

  • 0

We have a restlet server and client. We need to pass the error status and exception traces back to the client so that the client can take appropriate actions depending on the error status code. I read about StatusService and using response.setStatus() method but I can’t get the specific exceptions thrown during server side processing be displayed on client side. The DAO layer from the server throws specific DB related exceptions and status code such as (Unique key violation etc), which the client needs to see and take appropriate actions.

Also, what is the common way of doing this to have centralized error handling / processing on server and client side ? Filters ?

A brief example will really help.

Thanks,
Deep

  • 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-05-28T11:14:22+00:00Added an answer on May 28, 2026 at 11:14 am

    You can only send HTTP status codes and optionally your own description message. You can also send a representation of the error by overriding the getRepresentation in the StatusService.

    @Override
    public Status getStatus(Throwable throwable, Resource resource) {
        Status ret = null;
        Throwable cause = throwable.getCause();
        if (cause == null) {
            Status status = super.getStatus(throwable, resource);
            ret = new Status(status, throwable.getMessage());
            log.log(Level.SEVERE, "Unexpected resource exception <" + ret.toString() + "> for throwable of type <" + throwable + "> at resource <" + resource + ">");
        } else if (cause instanceof NotFoundException) {
            ret = new Status(Status.CLIENT_ERROR_NOT_FOUND, cause, resource.getReference().toString());
            log.info("Not found <" + ret.toString() + "> for throwable of type <" + cause + "> at resource <" + resource + ">");
        } else if (cause instanceof ConstraintViolationsException) {
            ConstraintViolationsException e = (ConstraintViolationsException) cause;
            ret = new Status(Status.CLIENT_ERROR_BAD_REQUEST, cause, e.getViolations().iterator().next().getMessage());
            log.log(Level.SEVERE, "Constraint violation <" + e.getViolations().iterator().next().getMessage() + "> at resource <" + resource + ">");
        } else if (cause instanceof BusinessRuleException) {
            ret = new Status(Status.CLIENT_ERROR_BAD_REQUEST, cause, cause.getMessage());
            log.log(Level.SEVERE, "Business rule exception: <" + cause.getMessage() + "> at resource <" + resource + ">");
        } else {
            Status status = super.getStatus(throwable, resource);
            ret = new Status(status, throwable.getMessage());
            log.log(Level.SEVERE, "Unexpected server exception <" + ret.toString() + "> for throwable of type <" + throwable + "> at resource <" + resource + ">");
        }
        return ret;
    }
    
    @Override
    public Representation getRepresentation(Status status, Request request, Response response) {
        String ret = "";
        if (status.getDescription() != null) {
            ret = status.getDescription();
        } else {
            ret = "unknown error";
        }
        return new StringRepresentation(ret, MediaType.TEXT_PLAIN);
    }
    

    You can return a representation of the error in getRepresentation in whatever format (XML, JSON, HTML) you want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have figured out that to integrate calls between Apache HTTP server and Restlet,
I have my Apache http server running on localhost:80 and restlet server on localhost:8182,
Have you ever seen any of there error messages? -- SQL Server 2000 Could
I have a Restlet Service that looks like this: @POST @Produces(application/json) public String processImmediately(String
I have an Eclipse project with a GWT client and a Restlet API. I
We have a small app with Restlet on the GAE server and GWT and
I have deployed our Restlet services to a Jetty Java Application server using the
I have : RESTLET GWT 2.1RC1 on the client RESTLET J2EE 2.1RC1 on the
I have 2 projects, one GWT/GAE and one GAE. Both implement the appropriate Restlet
Using Restlet I have created a router for my Java application. From using curl,

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.