mirror of
https://github.com/svek95/WST_Labs.git
synced 2026-05-18 02:51:45 +03:00
Add Exceptions for Lab3
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
package Lab3;
|
package Lab3;
|
||||||
|
|
||||||
|
import Lab1.CarWebService;
|
||||||
|
|
||||||
public class CarWebExcept {
|
public class CarWebExcept {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package Lab3.Exception;
|
||||||
|
|
||||||
|
public class CarServiceFault {
|
||||||
|
private String message;
|
||||||
|
private final static String TEMPLATE_MESSAGE = "Problem during %s operation. %s";
|
||||||
|
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CarServiceFault(String operation, String message) {
|
||||||
|
this.message = String.format(TEMPLATE_MESSAGE, operation, message);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package Lab3.Exception;
|
||||||
|
|
||||||
|
import javax.xml.ws.WebFault;
|
||||||
|
|
||||||
|
@WebFault(faultBean = "Lab3.Exception.CarServiceFault")
|
||||||
|
public class IDExcept extends Exception {
|
||||||
|
private CarServiceFault _CarServiceFault;
|
||||||
|
|
||||||
|
private final static String TEMPLATE_OF_MESSAGE = "Error during %s operation. " +
|
||||||
|
"Film with id %d is not found";
|
||||||
|
|
||||||
|
public IDExcept(Integer id, String command, CarServiceFault fault) {
|
||||||
|
super(String.format(TEMPLATE_OF_MESSAGE, command, id));
|
||||||
|
this._CarServiceFault = fault;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IDExcept(Integer id, String command, CarServiceFault fault, Throwable cause) {
|
||||||
|
super(String.format(TEMPLATE_OF_MESSAGE, command, id), cause);
|
||||||
|
this._CarServiceFault = fault;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CarServiceFault getFaultInfo() {
|
||||||
|
return _CarServiceFault;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package Lab3.Exception;
|
||||||
|
|
||||||
|
import javax.xml.ws.WebFault;
|
||||||
|
|
||||||
|
@WebFault(faultBean = "Lab3.Exception.CarServiceFault")
|
||||||
|
public class WrongValueExcept extends Exception{
|
||||||
|
private CarServiceFault _CarServiceFault;
|
||||||
|
|
||||||
|
private static final String MESSAGE_TEMPLATE = "Ooops, you try field %s value must be %s";
|
||||||
|
|
||||||
|
public WrongValueExcept(String fieldName, String possibleValues, CarServiceFault fault) {
|
||||||
|
super(String.format(MESSAGE_TEMPLATE, fieldName, possibleValues));
|
||||||
|
this._CarServiceFault = fault;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WrongValueExcept(String fieldName, String possibleValues, CarServiceFault fault, Throwable cause) {
|
||||||
|
super(String.format(MESSAGE_TEMPLATE, fieldName, possibleValues), cause);
|
||||||
|
this._CarServiceFault = fault;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CarServiceFault getFaultInfo() {
|
||||||
|
return _CarServiceFault;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user