mn8 Language Reference | Index    

Error

SUMMARY: NO ATTRIBUTES  NO ELEMENTS  CONSTRUCTORS SUMMARY  NO OPERATORS  METHODS SUMMARYDETAIL: NO ATTRIBUTES  NO ELEMENTS  CONSTRUCTOR DETAILS  NO OPERATORS  METHOD DETAILS

Description

An atomic concept for error handler. Creating this concept with its constructor (create) is equal with launching an error. This error will look for handlers (concepts and methods) to handle the error. If no handlers, it will apply the default methods (the methods error or warning). If no default (global) methods sets in concept, will show the default error message. An error concept can have two types: error and warning (plus one, the silent mode only for unit tests).

Usage

In the concept where you want to launch an error:

Can set an error handler concept (where to be a handler method): .setErrorHandler( concept )

Can obtain the handler concept: Concept handler = .getErrorHandler()

An error handler method look like this:

            : anyHandlerMethod ( $err typeof Error ) [
                #you can obtain the error message
                StringConcept msg = .getMSG()

                #you can set the error message
                .setMSG( "everything" )

                #you can obtain the error type (error or warning)
                StringConcept msg = .getType()

                #you can set the error type
                .setType( "warning" )

                #you can obtain the Concept passed over the constructor
                Concept msg = .getConcept()]

Version: 0.1
Authors:Antal Attila ()
Location:

Constructor List

create (String $type, String $id, String $msg)
create (String $type, String $id, String $msg, Concept $con)
top

Method List

ConceptgetConcept
StringgetType
StringgetMSG
static println (String $msg)
static print (String $msg)
setMSG (String $msg)
setType (String $type)
top

Detailed Constructor Info

create (String $type, String $id, String $msg)
Parameters:
$type :The error type
$id :The error handler method name
$msg :The error message

Create the Error concept specifying the type, method name and error message

top
create (String $type, String $id, String $msg, Concept $con)
Parameters:
$type :The error type
$id :The error handler method name
$msg :The error message
$con :Any Concept can passed here to handler

Create the Error concept specifying the type, method name, error message and an concept for handler.

top

Detailed Method Info

getConcept
Returns: Concept

In the handler method you can obtain the passed concept with this method.

            define Test [                                                                   
              :handlerMethod($e typeof Error) [                                            
                print $e.getConcept                                                      
              ]                                                                            
                                                                                
              static : main ($args typeof Series) [                                        
                $con typeof Test                                                           
                Test.setErrorHandler($con)                                                 
                Error.create("error", "handlerMethod", "This is an error message.", $con)  
              ]                                                                             
            ]
            -- the result is --
            Test
            

top
getType
Returns: String

Get the error type.

            $err typeof Error
            $err.setType("Warning")
            print $err.getType
            -- the result is --
            Warning
            

top
getMSG
Returns: String

Get the error message.

            $err typeof Error
            $err.setMSG("This is an ERROR message")
            print $err.getMSG
            -- the result is --
            This is an ERROR message
            

top
static println (String $msg)
Parameters:
$msg :the message
Returns:

Prints the specified message to the output stream adding an EOL at the end.

            Error.println("This is a test message.")
            -- the result is --
            This is a test message.
            

top
static print (String $msg)
Parameters:
$msg :the message
Returns:

Prints the specified message to the output stream.

            Error.print("This is a test message.")
            -- the result is --
            This is a test message.
            

top
setMSG (String $msg)
Parameters:
$msg :new error message
Returns:

Set the error message.

            $err typeof Error
            $err.setMSG("This is an ERROR message")
            print $err.getMSG
            -- the result is --
            This is an ERROR message
            

top
setType (String $type)
Parameters:
$type :new error type
Returns:

Set the error type.

            $err typeof Error
            $err.setType("Warning")
            print $err.getType
            -- the result is --
            Warning
            

top