Browse code

use inherits() to test class

Zuguang Gu authored on 24/01/2017 21:40:19
Showing 1 changed files

... ...
@@ -476,7 +476,7 @@ setMethod(f = "draw",
476 476
 				pushViewport(viewport(y = sum(anno_size[seq(i, n_anno)]) + sum(gap[seq(i, n_anno)]) - gap[n_anno], 
477 477
 					height = anno_size[i], just = c("center", "top")))
478 478
 				oe = try(draw(object@anno_list[[i]], index, k, n))
479
-				if("try-error" %in% class(oe)) {
479
+				if(inherits(oe, "try-error")) {
480 480
 					cat("Error when drawing annotation '", object@anno_list[[i]]@name, "'\n", sep = "")
481 481
 					stop(oe)
482 482
 				}
... ...
@@ -488,7 +488,7 @@ setMethod(f = "draw",
488 488
 				pushViewport(viewport(y = unit(1, "npc") - (sum(anno_size[seq_len(i)]) + sum(gap[seq_len(i)]) - gap[i]), 
489 489
 					height = anno_size[i], just = c("center", "bottom")))
490 490
 				oe = try(draw(object@anno_list[[i]], index, k, n))
491
-				if("try-error" %in% class(oe)) {
491
+				if(inherits(oe, "try-error")) {
492 492
 					cat("Error when drawing annotation '", object@anno_list[[i]]@name, "'\n", sep = "")
493 493
 					stop(oe)
494 494
 				}
... ...
@@ -499,7 +499,7 @@ setMethod(f = "draw",
499 499
 		for(i in seq_len(n_anno)) {
500 500
 			pushViewport(viewport(x = sum(anno_size[seq_len(i)]) + sum(gap[seq_len(i)]) - gap[i], width = anno_size[i], just = c("right", "center")))
501 501
 			oe = try(draw(object@anno_list[[i]], index, k, n))
502
-			if("try-error" %in% class(oe)) {
502
+			if(inherits(oe, "try-error")) {
503 503
 				cat("Error when drawing annotation '", object@anno_list[[i]]@name, "'\n", sep = "")
504 504
 				stop(oe)
505 505
 			}