Package com.betfair.baseline.v1.exception

Examples of com.betfair.baseline.v1.exception.SimpleException


        if (message.equals("throwRuntime")) {
            throw new RuntimeException("Requested");
        } else {
            try {
                SimpleExceptionErrorCodeEnum errCode = SimpleExceptionErrorCodeEnum.valueOf(message.toUpperCase(Locale.ENGLISH));
                throw new SimpleException(response, errCode, message);
            }
            catch (IllegalArgumentException e) {
                try {
                    WotsitExceptionErrorCodeEnum errCode = WotsitExceptionErrorCodeEnum.valueOf(message.toUpperCase(Locale.ENGLISH));
                    throw new WotsitException(e,
                            response,
                            errCode, (message.hashCode() % 2) != 0 ? WotsitExceptionTypeEnum.CHEESY : WotsitExceptionTypeEnum.SPICY,
                            String.valueOf(responseCode));
                }
                catch (IllegalArgumentException ex) {
                }
                throw new SimpleException(e,response, SimpleExceptionErrorCodeEnum.NULL, message);
            }
        }
    }
View Full Code Here


    ctx.setRequestLogExtension(new BaselineLogExtension(null, null, null));

    try {
      SimpleExceptionErrorCodeEnum errCode = SimpleExceptionErrorCodeEnum
          .valueOf(message);
      throw new SimpleException(ResponseCode.Unauthorised, errCode,
          message);
    } catch (IllegalArgumentException e) {
      try {
        WotsitExceptionErrorCodeEnum errCode = WotsitExceptionErrorCodeEnum
            .valueOf(message);
        throw new WotsitException(e,
            ResponseCode.Forbidden,
            errCode,
            (message.hashCode() % 2 != 0) ? WotsitExceptionTypeEnum.CHEESY
                : WotsitExceptionTypeEnum.SPICY, message);
      } catch (IllegalArgumentException ex) {
      }
      throw new SimpleException(e,ResponseCode.Unauthorised,
          SimpleExceptionErrorCodeEnum.NULL, message);
    }

  }
View Full Code Here

    @Override
    public void testSleep(RequestContext ctx, Long sleep, TimeConstraints timeConstraints) throws SimpleException {
        ctx.setRequestLogExtension(new BaselineLogExtension(sleep, null, null));

        if (sleep <= 0) {
            throw new SimpleException(ResponseCode.BadRequest, SimpleExceptionErrorCodeEnum.GENERIC, "Sleep must be > 0");
        }

        CountDownLatch latch = new CountDownLatch(1);
        outstandingSleeps.add(latch);
View Full Code Here

            response.add(sr);
        }
        if (async == AsyncBehaviour.SYNC) {
            return response;
        } else {
      throw new SimpleException(ResponseCode.ServiceUnavailable,SimpleExceptionErrorCodeEnum.FORBIDDEN ,"Suspend, is no longer supported");
        }
    }
View Full Code Here

            response.put(String.valueOf(i), sr);
        }
        if (async == AsyncBehaviour.SYNC) {
            return response;
        } else {
          throw new SimpleException(ResponseCode.ServiceUnavailable,SimpleExceptionErrorCodeEnum.FORBIDDEN ,"Suspend, is no longer supported");
        }
    }
View Full Code Here

    try {
      long sec = Long.parseLong(seconds);
      Thread.currentThread().sleep(sec * 1000);

    } catch (NumberFormatException e) {
      throw new SimpleException(ResponseCode.InternalError,SimpleExceptionErrorCodeEnum.GENERIC, e.getMessage());
    } catch (InterruptedException e) {
      throw new SimpleException(ResponseCode.Timeout,SimpleExceptionErrorCodeEnum.TIMEOUT,e.getMessage());
    }
    SimpleResponse response = new SimpleResponse();
    response.setMessage("Waited for " + seconds + " seconds.");
    return response;
  }
View Full Code Here

        try {
            nonExistentServiceClient.someOperation(ctx);
        }
        // this won't hit as this call will return a not found..
        catch (com.betfair.nonservice.v3.exception.SimpleException e) {
            throw new SimpleException(SimpleExceptionErrorCodeEnum.valueOf(e.getErrorCode().name()),e.getReason());
        }
    }
View Full Code Here

            ExecutionObserver observer = longEventNamespacedExecutionObserver.get(eventNamespace);
            LongEvent longEvent = new LongEvent();
            longEvent.setLongArg(longArg);
            observer.onResult(new ExecutionResult(longEvent));
        } else {
            throw new SimpleException(ResponseCode.BadRequest,  SimpleExceptionErrorCodeEnum.GENERIC,
                    "Unknown event namespace: "+ eventNamespace);
        }
    }
View Full Code Here

TOP

Related Classes of com.betfair.baseline.v1.exception.SimpleException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.