Exception: SyntaxError

Inherits:
ScriptError show all
Defined in:
error.c,
error.c

Overview

Raised when encountering Ruby code with an invalid syntax.

eval("1+1=2")

raises the exception:

SyntaxError: (eval):1: syntax error, unexpected '=', expecting $end

Instance Method Summary collapse

Methods inherited from Exception

#==, #backtrace, #backtrace_locations, #cause, #exception, exception, #full_message, #inspect, #message, #set_backtrace, #to_s, to_tty?

Constructor Details

#new([msg]) ⇒ Object

Construct a SyntaxError exception.



2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
# File 'error.c', line 2104

static VALUE
syntax_error_initialize(int argc, VALUE *argv, VALUE self)
{
    VALUE mesg;
    if (argc == 0) {
	mesg = rb_fstring_lit("compile error");
	argc = 1;
	argv = &mesg;
    }
    return rb_call_super(argc, argv);
}