Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add Memcached::ATimeoutOccurred exception

  • Loading branch information...
commit 8c7304af49ee5be91d4751dd223dad333a9a5f2c 1 parent 00189b2
@flyerhzm flyerhzm authored
View
51 src/main/java/com/openfeint/memcached/Memcached.java
@@ -9,6 +9,7 @@
import net.spy.memcached.ConnectionFactoryBuilder.Protocol;
import net.spy.memcached.DefaultHashAlgorithm;
import net.spy.memcached.MemcachedClient;
+import net.spy.memcached.OperationTimeoutException;
import net.spy.memcached.transcoders.Transcoder;
import org.jruby.Ruby;
import org.jruby.RubyArray;
@@ -96,10 +97,12 @@ public IRubyObject add(ThreadContext context, IRubyObject[] args) {
throw Error.newNotStored(ruby, "not stored");
}
return context.nil;
- } catch (ExecutionException ee) {
- throw ruby.newRuntimeError(ee.getLocalizedMessage());
- } catch (InterruptedException ie) {
- throw ruby.newThreadError(ie.getLocalizedMessage());
+ } catch (OperationTimeoutException e) {
+ throw Error.newATimeoutOccurred(ruby, e.getLocalizedMessage());
+ } catch (ExecutionException e) {
+ throw ruby.newRuntimeError(e.getLocalizedMessage());
+ } catch (InterruptedException e) {
+ throw ruby.newThreadError(e.getLocalizedMessage());
}
}
@@ -115,10 +118,12 @@ public IRubyObject replace(ThreadContext context, IRubyObject [] args) {
throw Error.newNotStored(ruby, "not stored");
}
return context.nil;
- } catch (ExecutionException ee) {
- throw ruby.newRuntimeError(ee.getLocalizedMessage());
- } catch (InterruptedException ie) {
- throw ruby.newThreadError(ie.getLocalizedMessage());
+ } catch (OperationTimeoutException e) {
+ throw Error.newATimeoutOccurred(ruby, e.getLocalizedMessage());
+ } catch (ExecutionException e) {
+ throw ruby.newRuntimeError(e.getLocalizedMessage());
+ } catch (InterruptedException e) {
+ throw ruby.newThreadError(e.getLocalizedMessage());
}
}
@@ -134,10 +139,12 @@ public IRubyObject set(ThreadContext context, IRubyObject[] args) {
throw Error.newNotStored(ruby, "not stored");
}
return context.nil;
- } catch (ExecutionException ee) {
- throw ruby.newRuntimeError(ee.getLocalizedMessage());
- } catch (InterruptedException ie) {
- throw ruby.newThreadError(ie.getLocalizedMessage());
+ } catch (OperationTimeoutException e) {
+ throw Error.newATimeoutOccurred(ruby, e.getLocalizedMessage());
+ } catch (ExecutionException e) {
+ throw ruby.newRuntimeError(e.getLocalizedMessage());
+ } catch (InterruptedException e) {
+ throw ruby.newThreadError(e.getLocalizedMessage());
}
}
@@ -194,10 +201,12 @@ public IRubyObject delete(ThreadContext context, IRubyObject key) {
throw Error.newNotFound(ruby, "not found");
}
return context.nil;
- } catch (ExecutionException ee) {
- throw ruby.newRuntimeError(ee.getLocalizedMessage());
- } catch (InterruptedException ie) {
- throw ruby.newThreadError(ie.getLocalizedMessage());
+ } catch (OperationTimeoutException e) {
+ throw Error.newATimeoutOccurred(ruby, e.getLocalizedMessage());
+ } catch (ExecutionException e) {
+ throw ruby.newRuntimeError(e.getLocalizedMessage());
+ } catch (InterruptedException e) {
+ throw ruby.newThreadError(e.getLocalizedMessage());
}
}
@@ -207,10 +216,12 @@ public IRubyObject flush(ThreadContext context) {
try {
client.flush().get();
return context.nil;
- } catch (ExecutionException ee) {
- throw ruby.newRuntimeError(ee.getLocalizedMessage());
- } catch (InterruptedException ie) {
- throw ruby.newThreadError(ie.getLocalizedMessage());
+ } catch (OperationTimeoutException e) {
+ throw Error.newATimeoutOccurred(ruby, e.getLocalizedMessage());
+ } catch (ExecutionException e) {
+ throw ruby.newRuntimeError(e.getLocalizedMessage());
+ } catch (InterruptedException e) {
+ throw ruby.newThreadError(e.getLocalizedMessage());
}
}
View
1  src/main/java/com/openfeint/memcached/MemcachedService.java
@@ -29,6 +29,7 @@ public IRubyObject allocate(Ruby ruby, RubyClass klazz) {
memcached.defineClassUnder("NotFound", memcachedError, memcachedError.getAllocator());
memcached.defineClassUnder("NotStored", memcachedError, memcachedError.getAllocator());
memcached.defineClassUnder("NotSupport", memcachedError, memcachedError.getAllocator());
+ memcached.defineClassUnder("ATimeoutOccurred", memcachedError, memcachedError.getAllocator());
return true;
}
}
View
7 src/main/java/com/openfeint/memcached/error/ATimeoutOccurred.java
@@ -0,0 +1,7 @@
+package com.openfeint.memcached.error;
+
+import org.jruby.anno.JRubyClass;
+
+@JRubyClass(name="Memcached::ATimeoutOccurred", parent="Memcached::Error")
+public class ATimeoutOccurred extends Error {
+}
View
4 src/main/java/com/openfeint/memcached/error/Error.java
@@ -20,6 +20,10 @@ public static RaiseException newNotSupport(Ruby ruby, String message) {
return newMemcachedError(ruby, "NotSupport", message);
}
+ public static RaiseException newATimeoutOccurred(Ruby ruby, String message) {
+ return newMemcachedError(ruby, "ATimeoutOccurred", message);
+ }
+
private static RaiseException newMemcachedError(Ruby ruby, String klass, String message) {
RubyClass errorClass = ruby.getModule("Memcached").getClass(klass);
return new RaiseException(RubyException.newException(ruby, errorClass, message), true);
View
BIN  target/spymemcached-ext-0.0.1.jar
Binary file not shown
Please sign in to comment.
Something went wrong with that request. Please try again.