Module: MaRuKu::Errors

Included in:
MDElement
Defined in:
lib/amp-front/third_party/maruku.rb,
lib/amp-front/third_party/maruku/errors_management.rb

Instance Method Summary collapse

Instance Method Details

#create_frame(s) ⇒ Object



70
71
72
73
74
75
76
77
78
79
80
# File 'lib/amp-front/third_party/maruku/errors_management.rb', line 70

def create_frame(s)
	n = 75
	"\n" +
	" "+"_"*n + "\n"+
	"| Maruku tells you:\n" +
	"+" + ("-"*n) +"\n"+
	add_tabs(s,1,'| ') + "\n" +
	"+" + ("-"*n) + "\n" +
	add_tabs(caller[0, 5].join("\n"),1,'!') + "\n" +
	"\\" + ("_"*n) + "\n"
end

#describe_error(s, src, con) ⇒ Object



82
83
84
85
86
87
# File 'lib/amp-front/third_party/maruku/errors_management.rb', line 82

def describe_error(s,src,con)
	t = s
	src && (t += "\n#{src.describe}\n")
	con && (t += "\n#{con.describe}\n")
	t
end

#maruku_error(s, src = nil, con = nil) ⇒ Object Also known as: error



41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/amp-front/third_party/maruku/errors_management.rb', line 41

def maruku_error(s,src=nil,con=nil)
	policy = get_setting(:on_error)
	
	case policy
	when :ignore 
	when :raise
		raise_error create_frame(describe_error(s,src,con))
	when :warning
		tell_user create_frame(describe_error(s,src,con))
	else
		raise "BugBug: policy = #{policy.inspect}"
	end
end

#maruku_recover(s, src = nil, con = nil) ⇒ Object



55
56
57
# File 'lib/amp-front/third_party/maruku/errors_management.rb', line 55

def maruku_recover(s,src=nil,con=nil)
	tell_user create_frame(describe_error(s,src,con))
end

#raise_error(s) ⇒ Object

Raises:



61
62
63
# File 'lib/amp-front/third_party/maruku/errors_management.rb', line 61

def raise_error(s)
	raise MaRuKu::Exception, s, caller
end

#tell_user(s) ⇒ Object



65
66
67
68
# File 'lib/amp-front/third_party/maruku/errors_management.rb', line 65

def tell_user(s)
	error_stream = self.attributes[:error_stream] || $stderr
	error_stream << s 
end