I have developed a REST application and one of my application's case is that:
User makes an operation at server side. Everything goes well server accepts data correctly however some error occurs as like communicating with database. I don't want to return it with an error code I want to send it with a success code but has a body that indicates error. I want to send error codes for 500, 404 and etc. Is my design is correct and which status code should I return for my case?
Some kind of 5xx error would be the most appropriate in this case.
500 for some kind of internal server error or
503 for service unavailable
Look here for all the error codes for HTTP/1.1 http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
You should always return an error code for your rest service if this is appropriate. Returning a success code but putting an error in your response isn't the right thing to do.