Exceptions

Exceptions typically indicate unexpected situations occuring during program execution. Exceptions are caught with the try statement (See See Try Statement) and generated with the Throw built-in function. Processing exceptions require knowledged about the format of exception objects, in particularly the type of the exception, which allows you to distinguish between the possible situations that occurred.

See Exceptions thrown by the built-in functions lists the exceptions thrown by the built-in WebL functions. By convention, the exception type (eg ArgumentError etc.) is indicated by the type field of the exception object. Also by convention, the msg field of the exception object gives information on why the exception occured.

Operators and statements can also generate exceptions, as explained in the following paragraphs.

All operators will throw an OperandMismatch exception in case the operands to the operator are not of the expected value type.

Function or method application (eg calling a function or method) can throw the following exceptions:

NoSuchField - Object does not have such field.

NotAFunctionOrMethod - Left-hand side is not callable.

NotAnObject - Left hand side is not an object.

ArgumentError - Number of actual and formal arguments do not match.

Variable assigment with "=" can throw the following exceptions:

FieldError - Unknown field or illegal field assignment.

NotAnObject - Left hand side is not an object field.

NotAVariable - Left hand side is not a variable.

Field definition with ":=" can throw the following exceptions:

FieldDefinitionError - Could not define field.

NotAnObject - Left hand side is not an object.

Indexing into a type with "[ ]" or "." can throw the following exceptions:

IndexRangeError - Index is out of range.

ArgumentError - Index is not of the expected type.

NoSuchField - Object does not have such field.

NotAnObject - Left hand side is not an object.

The if, repeat, while and catch statements will throw a GuardError exception if the guard expression does not return a boolean value type.

The every statement will throw a NotEnumerable exception if the object does not have enumerable contents.

The lock statement will throw a NotAnObject exception if an attempt is made to lock on a non-object value type.

 

Exceptions thrown by the built-in functions

Function

Exceptions

Assert(x: bool): nil

ArgumentError - Incorrect or wrong number of arguments

AssertFailed - Assertion failed

BeginTag(q: piece): tag

ArgumentError - Incorrect or wrong number of arguments

Boolp(x): bool

ArgumentError - Incorrect or wrong number of arguments

Exec(cmd: string): int

ArgumentError - Incorrect or wrong number of arguments

Charp(x): bool

ArgumentError - Incorrect or wrong number of arguments

Children(q: piece): pieceset

ArgumentError - Incorrect or wrong number of arguments

Clone(o: object, p: object, ...): object

ArgumentError - Incorrect or wrong number of arguments

Content(p: page): piece
Content(q: piece): piece

NoContent - Page or piece has no content

ArgumentError - Incorrect or wrong number of arguments

Delete(s: pieceset): nil
Delete(q: piece): nil

ArgumentError - Incorrect or wrong number of arguments

Elem(p: page): pieceset
Elem(p: page, name: string): pieceset
Elem(q: piece): pieceset
Elem(q: piece, name: string): pieceset

ArgumentError - Incorrect or wrong number of arguments

EndTag(q: piece): tag

ArgumentError - Incorrect or wrong number of arguments

Error(x, y, z, ...): nil

No exceptions are thrown

ErrorLn(x, y, z, ...): nil

No exceptions are thrown

Eval(s: string): any

ArgumentError - Incorrect or wrong number of arguments

SyntaxError - Cannot evaluate due to syntax error in argument

IOException - An IO exception occurred during function execution

ReturnException - A return statement was executed outside of a function or method while executing the argument

Exec(cmd: string): int

ArgumentError - Incorrect or wrong number of arguments

Exit(errorcode: int): nil

ArgumentError - Incorrect or wrong number of arguments

ExpandCharEntities(p: page, s: string): string
ExpandCharEntities(s: string): string

ArgumentError - Incorrect or wrong number of arguments

IOException - An IO exception occurred during function execution

First(l: list): any

ArgumentError - Incorrect or wrong number of arguments

EmptyList - Cannot apply first to an empty list

Flatten(s: pieceset): pieceset

ArgumentError - Incorrect or wrong number of arguments

Funp(x): bool

ArgumentError - Incorrect or wrong number of arguments

GC(): nil

ArgumentError - Incorrect or wrong number of arguments

GetURL(url: string): page)
GetURL(url: string, params: {object, string}): page)
GetURL(url: string, params: {object, string}, headers: object): page)
GetURL(url: string, params: {object, string}, headers: object, options: object): page)

ArgumentError - Incorrect or wrong number of arguments

NetException - Fetch failed, "statuscode" field of the exception object indicates the reason

GetURL(url: string): page)
GetURL(url: string, params: {object, string}): page)
GetURL(url: string, params: {object, string}, headers: object): page)

ArgumentError - Incorrect or wrong number of arguments

NetException - Fetch failed, "statuscode" field of the exception object indicates the reason

InsertAfter(t: tag; q: piece): nil
InsertAfter(t: tag; s: pieceset): nil

ArgumentError - Incorrect or wrong number of arguments

InsertBefore(t: tag; q: piece): nil
InsertBefore(t: tag; s: pieceset): nil

ArgumentError - Incorrect or wrong number of arguments

Intp(x): bool

ArgumentError - Incorrect or wrong number of arguments

Listp(x): bool

ArgumentError - Incorrect or wrong number of arguments

Markup(P: page): string
Markup(q: piece): string

ArgumentError - Incorrect or wrong number of arguments

Methp(x): bool

ArgumentError - Incorrect or wrong number of arguments

Name(q: piece): string

ArgumentError - Incorrect or wrong number of arguments

Native(classname: string): fun

ArgumentError - Incorrect or wrong number of arguments

NativeCodeImportError - Class instantiation failed, access denied, no such method, or not a sub-class of built-in

NewNamedPiece(name: string, t1: tag, t2: tag): piece
NewNamedPiece(name: string, q: piece): piece

ArgumentError - Incorrect or wrong number of arguments

NotSamePage - The tag arguments to the function do not belong to the same page

NewPage(s: string, mimetype: string): page

ArgumentError - Incorrect or wrong number of arguments

NetException - Fetch failed, "statuscode" field of the exception object indicates the reason

NewPiece(q: piece): piece
NewPiece(s: string, mimetype: string): piece
NewPiece(t1: tag, t2: tag): piece

ArgumentError - Incorrect or wrong number of arguments

NotSamePage - The tag arguments to the function do not belong to the same page

NewPieceSet(p: page): pieceset

ArgumentError - Incorrect or wrong number of arguments

NotAPiece - The set argument to NewPieceSet must only contain pieces

EmptySet - The set argument to NewPieceSet must only contain pieces belonging to the same page

NotSamePage - The set argument to NewPieceSet must only contain pieces belonging to the same page

Objectp(x): bool

ArgumentError - Incorrect or wrong number of arguments

PCData(p: page): pieceset
PCData(p: piece): pieceset

ArgumentError - Incorrect or wrong number of arguments

Page(q: piece): page
Page(t: tag): page

ArgumentError - Incorrect or wrong number of arguments

Pagep(x): bool

ArgumentError - Incorrect or wrong number of arguments

Para(p: page, paraspec: string): pieceset
Para(q: piece, paraspec: string): pieceset

ArgumentError - Incorrect or wrong number of arguments

Parent(q: piece): piece

ArgumentError - Incorrect or wrong number of arguments

Pat(p: page, regexp: string): pieceset
Pat(q: piece, regexp: string): pieceset

ArgumentError - Incorrect or wrong number of arguments

MalformedPattern - Illegal regular expression passed to Pat function

PieceSetp(x): bool

ArgumentError - Incorrect or wrong number of arguments

Piecep(x): bool

ArgumentError - Incorrect or wrong number of arguments

PostURL(url: string): page)
PostURL(url: string, params: {object, string}): page)
PostURL(url: string, params: {object, string}, headers: object): page)
PostURL(url: string, params: {object, string}, headers: object, options: object): page)

ArgumentError - Incorrect or wrong number of arguments

NetException - Fetch failed, "statuscode" field of the exception object indicates the reason

IOException - An IO exception occurred during function execution

Pretty(p: page): string
Pretty(q: piece): string

ArgumentError - Incorrect or wrong number of arguments

Print(x, y, z, ...): nil

No exceptions are thrown

PrintLn(x, y, z, ...): nil

No exceptions are thrown

ReadLn(): string

ArgumentError - Incorrect or wrong number of arguments

IOException - An IO exception occurred during function execution

Realp(x): bool

ArgumentError - Incorrect or wrong number of arguments

Replace(a: pieceset, b: pieceset): nil

ArgumentError - Incorrect or wrong number of arguments

Rest(l: list): list

ArgumentError - Incorrect or wrong number of arguments

Retry(x): any

ArgumentError - Incorrect or wrong number of arguments

Select(s: set: f: fun): set
Select(l: list, f: fun): list
Select(p: pieceset, f: fun): pieceset
Select(s: string, from: int, to: int): string

ArgumentError - Incorrect or wrong number of arguments

Seq(p: page, pattern: string): pieceset
Seq(q: piece, pattern: string): pieceset

ArgumentError - Incorrect or wrong number of arguments

IndexRangeError - Index into list or string out of bounds

FunctionReturnTypeNotBoolean - Function argument to Select did not return a boolean value

Setp(x): bool

ArgumentError - Incorrect or wrong number of arguments

Sign(x: int): int
Sign(x: real): int

ArgumentError - Incorrect or wrong number of arguments

Size(s: set):int
Size(s: string): int
Size(l: list): int

ArgumentError - Incorrect or wrong number of arguments

Sleep(ms: int): nil

ArgumentError - Incorrect or wrong number of arguments

Interrupted - Sleep function interrupted

Sort(l: list, f: fun): list

ArgumentError - Incorrect or wrong number of arguments

FunctionReturnTypeNotInteger - Function argument to Sort did not return an integer value

Stall()

ArgumentError - Incorrect or wrong number of arguments

Stringp(x): bool

ArgumentError - Incorrect or wrong number of arguments

Tagp(x): bool

ArgumentError - Incorrect or wrong number of arguments

Text(p: page): string
Text(q: piece): string

ArgumentError - Incorrect or wrong number of arguments

Throw(o: object)

ArgumentError - Incorrect or wrong number of arguments

Time(x): int

ArgumentError - Incorrect or wrong number of arguments

Timeout(ms: int, x): any

ArgumentError - Incorrect or wrong number of arguments

Timeout - A time out occurred

ToChar(c: char): char
ToChar(i: int): char

ArgumentError - Incorrect or wrong number of arguments

ToInt(c: char): int
ToInt(i: int): int
ToInt(r: real): int
ToInt(s: string): int

ArgumentError - Incorrect or wrong number of arguments

ToList(s: set): list
ToList(l: list): list
ToList(s: string): list
ToList(o: object): list
ToList(p: pieceset): list

ArgumentError - Incorrect or wrong number of arguments

ToReal(c: char): real
ToReal(i: int): real
ToReal(r: real): real
ToReal(s: string): real

ArgumentError - Incorrect or wrong number of arguments

ToSet(s: set): set
ToSet(l: list): set
ToSet(s: string): set
ToSet(o: object): set
ToSet(p: pieceset): set

ArgumentError - Incorrect or wrong number of arguments

ToString(x): string

ArgumentError - Incorrect or wrong number of arguments

Trap(x): object

ArgumentError - Incorrect or wrong number of arguments

ToString(x): string

ArgumentError - Incorrect or wrong number of arguments

 


Up Previous Next