1 /* 2 * Copyright the original author or authors. 3 * 4 * Licensed under the MOZILLA PUBLIC LICENSE, Version 1.1 (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.mozilla.org/MPL/MPL-1.1.html 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 import org.as2lib.core.BasicClass; 18 19 /** 20 * {@code MethodInvocationErrorInfo} informs the client of an error that occured on 21 * a method invocation. 22 * 23 * <p>It defines constants, that can be used to identify what kind of error occured. 24 * 25 * <p>This class is used in conjunction with the {@link MethodInvocationCallback} 26 * and {@link MethodInvocationErrorListener} classes. 27 * 28 * @author Simon Wacker 29 */ 30 class org.as2lib.io.conn.core.event.MethodInvocationErrorInfo extends BasicClass { 31 32 /** Indicates an error of unknown origin. */ 33 public static var UNKNOWN_ERROR:Number = 0; 34 35 /** Indicates an error caused because of a not existing service. */ 36 public static var UNKNOWN_SERVICE_ERROR:Number = 1; 37 38 /** Indicates that the method to invoke does not exist. */ 39 public static var UNKNOWN_METHOD_ERROR:Number = 2; 40 41 /** Indicates an error caused by arguments that are out of size. */ 42 public static var OVERSIZED_ARGUMENTS_ERROR:Number = 3; 43 44 /** Indicates that the service method to invoke threw an exception. */ 45 public static var METHOD_EXCEPTION_ERROR:Number = 4; 46 47 /** Url of the service the method should have been invoked on. */ 48 private var serviceUrl:String; 49 50 /** The name of the method to be executed. */ 51 private var methodName:String; 52 53 /** The arguments used for the invocation. */ 54 private var methodArguments:Array; 55 56 /** A number indicating the type of the error. */ 57 private var errorCode:Number; 58 59 /** The exception that caused the error. */ 60 private var exception; 61 62 /** 63 * Constructs a new {@code MethodInvocationErrorInfo} instance. 64 * 65 * <p>If {@code errorCode} is {@code null} or {@code undefined}, {@link #UNKNOWN_ERROR} 66 * is used. 67 * 68 * @param serviceUrl the url to the service the method should be or was invoked on 69 * @param methodName the name of the method that should be or was invoked on the service 70 * @param methodArguments the arguments used as parameters for the method invocation 71 * @param error a number indicating the type of the error 72 * @param exception the exception that caused the error 73 */ 74 public function MethodInvocationErrorInfo(serviceUrl:String, methodName:String, methodArguments:Array, errorCode:Number, exception) { 75 this.serviceUrl = serviceUrl; 76 this.methodName = methodName; 77 this.methodArguments = methodArguments; 78 this.errorCode = errorCode == null ? UNKNOWN_ERROR : errorCode; 79 this.exception = exception == null ? null : exception; 80 } 81 82 /** 83 * Returns the url to the service the method should be or was invoked on. 84 * 85 * @return the url to the service the method should be or was invoked on 86 */ 87 public function getServiceUrl(Void):String { 88 return serviceUrl; 89 } 90 91 /** 92 * Returns the name of the method that caused this error. 93 * 94 * @return the name of the method that should be or was invoked on the service 95 */ 96 public function getMethodName(Void):String { 97 return methodName; 98 } 99 100 /** 101 * Returns the arguments used as parameters for the method invocaton 102 * that caused this error. 103 * 104 * @return the arguments used as parameters for the method invocation 105 */ 106 public function getMethodArguments(Void):Array { 107 return methodArguments; 108 } 109 110 /** 111 * Returns the error code that describes this error. 112 * 113 * <p>The error code matches one of the declared error constants. 114 * 115 * @return the error code that describes the type of this error 116 */ 117 public function getErrorCode(Void):Number { 118 return errorCode; 119 } 120 121 /** 122 * Returns the exception that caused this error. 123 * 124 * <p>Note that this error is not always caused by an exception. This method may 125 * does also return {@code null}. 126 * 127 * @return the exception that caused this error or {@code null} 128 */ 129 public function getException(Void) { 130 return exception; 131 } 132 133 }