Exception: PHPVM::PHPErrorReporting

Inherits:
PHPError
  • Object
show all
Defined in:
ext/php_vm/php_vm.c

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Object

class PHPVM::PHPErrorReporting



1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
# File 'ext/php_vm/php_vm.c', line 1186

VALUE rb_php_error_reporting_initialize(int argc, VALUE *argv, VALUE self)
{
	VALUE log_message = Qnil;
	VALUE error_level = Qnil;
	VALUE message = Qnil;
	VALUE file = Qnil;
	VALUE line = Qnil;

	if (argc==1 && TYPE(argv[0])==T_STRING) {
		log_message = argv[0];
		VALUE re_str = rb_str_new2("^PHP ([^:]+?)(?: error)?: {0,2}(.+) in (.+) on line (\\d+)$");
		VALUE re_option = rb_const_get(rb_cRegexp, rb_intern("MULTILINE"));
		VALUE report_re = rb_funcall(rb_cRegexp, rb_intern("new"), 2, re_str, re_option);
		VALUE m = rb_funcall(argv[0], rb_intern("match"), 1, report_re);
		if (m!=Qnil) {
			error_level = rb_funcall(m, rb_intern("[]"), 1, INT2NUM(1));
			error_level = ID2SYM(rb_intern(RSTRING_PTR(error_level)));
			message = rb_funcall(m, rb_intern("[]"), 1, INT2NUM(2));
			file = rb_funcall(m, rb_intern("[]"), 1, INT2NUM(3));
			line = rb_funcall(m, rb_intern("[]"), 1, INT2NUM(4));
			line = rb_funcall(line, rb_intern("to_i"), 0);
			argv[0] = message;
		}
	}
	rb_call_super(argc, argv);

	rb_iv_set(self, "log_message", log_message);
	rb_iv_set(self, "error_level", error_level);
	rb_iv_set(self, "file", file);
	rb_iv_set(self, "line", line);

	return self;
}

Instance Method Details

#error_levelObject



1225
1226
1227
1228
# File 'ext/php_vm/php_vm.c', line 1225

VALUE rb_php_error_reporting_error_level(VALUE self)
{
	return rb_iv_get(self, "error_level");
}

#fileObject



1230
1231
1232
1233
# File 'ext/php_vm/php_vm.c', line 1230

VALUE rb_php_error_reporting_file(VALUE self)
{
	return rb_iv_get(self, "file");
}

#lineObject



1235
1236
1237
1238
# File 'ext/php_vm/php_vm.c', line 1235

VALUE rb_php_error_reporting_line(VALUE self)
{
	return rb_iv_get(self, "line");
}

#log_messageObject



1220
1221
1222
1223
# File 'ext/php_vm/php_vm.c', line 1220

VALUE rb_php_error_reporting_log_message(VALUE self)
{
	return rb_iv_get(self, "log_message");
}