E2021 Class type required (Object Pascal)

From Appmethod Topics
Jump to: navigation, search

Go Up to Error and Warning Messages (Object Pascal) Index

In certain situations the compiler requires a class type:

  • As the ancestor of a class type
  • In the on-clause of a try-except statement
  • As the first argument of a raise statement
  • As the final type of a forward declared class type


program Produce;
begin
  raise 'This would work in C++, but does not in Object Pascal';
end.
	program Solve;
uses SysUtils;
begin
  raise Exception.Create('There is a simple workaround, however');
end.