Slide 79
Slide 79 text
class WrongEncodingError < EncodingError
def initialize(string, encoding)
@string, @encoding = string, encoding
end
def message
@string.force_encoding("BINARY")
"Your template was not saved as " \
"valid #{@encoding}. Please either " \
"specify #{@encoding} as the encoding " \
"for your template in your text " \
"editor,or mark the template with its " \
"encoding by inserting the following " \
"as the first line of the template:" \
"\n\n# encoding: .\n\nThe source of your " \
"template was:\n\n#{@string}"
end
end
CUSTOM EXCEPTION.