#INCLUDE COMUN.H

Define Class appBaseController As Custom
	oSettings = Null
	lError = .F.
	cErrorMessage = ''
	oLog = Null
	*
	Procedure Init
		This.oSettings = Createobject("settingsBaseController")
		This.oLog = Iif(Type('goLog') = 'O', goLog, Createobject("logBaseController"))
	Endproc && INIT
	*
	Procedure ProcessError(toHash)
		Declare laErrors[1]

		lnErrorLines = Aerror(laErrors)

		lnError = Iif(toHash.HasProperty("nError"), toHash.GetValue("nError"), Transform(laErrors(1)) + ' ' + Transform(laErrors(5)))
		lcMethod = toHash.GetValue("cMethod")
		lnLine = toHash.GetValue("nLine")
		lcError = Iif(toHash.HasProperty("cError"), toHash.GetValue("cError"), Transform(laErrors(2)))
		lcCode = Iif(toHash.HasProperty("cCode"), toHash.GetValue("cCode"), Message(1) )
		lcCallStack = GetCallStack()
		lcUserMessage = toHash.GetValue("cUserMessage")

		This.cErrorMessage = lcUserMessage + CRLF + CRLF + ;
			'Eroarea nr: ' + Transform(lnError) + CRLF + ;
			'Eroarea: ' + Transform(lcError) + CRLF + ;
			'Procedura: ' + Transform(lcMethod) + CRLF + ;
			'Linia: ' + Transform(lnLine) + CRLF + ;
			'Codul: ' + Transform(lcCode) + CRLF + ;
			lcCallStack

		This.lError = .T.
		This.oLog.WriteLog(This.cErrorMessage)

		aMessagebox(This.cErrorMessage,0+16,'Eroare')
		*!*			IF MESSAGEBOX(THIS.cErrorMessage + CRLF + 'Doriti sa iesiti?',16+4,'Eroare') = 6
		*!*				RETURN TO MASTER
		*!*			ENDIF
	Endproc && ProcessError
	*
	Procedure Log
		Lparameters tcMessage
		This.oLog.WriteLog(tcMessage)
	Endproc && Log
	*
	Function GetError
		Return This.cErrorMessage
	Endfunc && GetError
	*
	Function HasError
		Return This.lError
	Endfunc && HasError

	*
	Function Gethost
		Return ""
	Endfunc && GetHost
	*
	Function GetUser
		Return ""
	Endfunc && GetUser
	*
	Function GetPassword
		Return ""
	Endfunc && GetPassword

Enddefine