first of all i am confuse right now and might not be able to explain myself properly. let me try. i have a business layer class which contain all the methods which are called from UI layer aspx pages. usually if a method throws an exception, i catch it on UI layer and display a certain message. if not, some times i catch on business layer and log the error only. Now i have created a third project/layer which will interact with external apis(like VISA) and i will call its methods from with in business layer methods. After api call, i return a certain object which contain json response, error codes and description etc. in case of error(exception) i need to show message to user. how can i do that while on business layer(best way. i can offcourse return error string or empty string in case of success)? or i have to call apis from UI layer? here is a response object which will be send by api layer. i will show error or proceed on bases its content.

public class ResponseContainer
{
    public bool Success { get; set; }
    public string JSONString { get; set; }
    public string ErrorCode { get; set; }
    public string ErrorDescription { get; set; }
    public bool? isVISAError { get; set; }
}
有帮助吗?

解决方案

as no body able to direct me, here is what i did. i made 2 custom exception class. business and sql exception. catching sql exception on business layer and throwing a new business exception. all business exception are being catch on calling events of UI layer. in case of visa error, i threw a new business exception with description and catch and displayed on simple label field. through this, i do not have to change flow of my code or check for return value of any of my functions.
i hope this will help few and if anyone has any better solution, please let me know

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top