Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
14792 manas 1
/**
2
 * Copyright 2010-present Facebook.
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *    http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
 
17
package com.facebook;
18
 
19
/**
20
 * Represents an error returned from the Facebook service in response to a request.
21
 */
22
public class FacebookServiceException extends FacebookException {
23
 
24
    private final FacebookRequestError error;
25
 
26
    private static final long serialVersionUID = 1;
27
 
28
    /**
29
     * Constructs a new FacebookServiceException.
30
     *
31
     * @param error the error from the request
32
     */
33
    public FacebookServiceException(FacebookRequestError error, String errorMessage) {
34
        super(errorMessage);
35
        this.error = error;
36
    }
37
 
38
    /**
39
     * Returns an object that encapsulates complete information representing the error returned by Facebook.
40
     *
41
     * @return complete information representing the error.
42
     */
43
    public final FacebookRequestError getRequestError() {
44
        return error;
45
    }
46
 
47
    @Override
48
    public final String toString() {
49
        return new StringBuilder()
50
                .append("{FacebookServiceException: ")
51
                .append("httpResponseCode: ")
52
                .append(error.getRequestStatusCode())
53
                .append(", facebookErrorCode: ")
54
                .append(error.getErrorCode())
55
                .append(", facebookErrorType: ")
56
                .append(error.getErrorType())
57
                .append(", message: ")
58
                .append(error.getErrorMessage())
59
                .append("}")
60
                .toString();
61
    }
62
 
63
}