TBASS_ErrorToString
issueid=283 15-05-2011 12:42
Super Moderator
Number of reported issues by Petr Schreiber: 126
TBASS_ErrorToString
TBASS_ErrorGetString is slightly cryptic, I would recommend having this for more comfort when debugging

Hi,

I would like to see TBASS_ErrorToString function implemented, as it would more friendly to programmer when debugging. As it is not present in original TBASS, I attach code and documentation:

Code:
function Exec_TBASS_ErrorToString() AS STRING

  dim nError as long
  nError = thinBasic_Parse1Number()

  Function = "Unknown error ("+format$(nError)+")"

  Select Case nError
    Case 0 : Function = "TBASS_OK" 
    Case 1 : Function = "TBASS_ERROR_MEM" 
    Case 2 : Function = "TBASS_ERROR_FILEOPEN" 
    Case 3 : Function = "TBASS_ERROR_DRIVER" 
    Case 4 : Function = "TBASS_ERROR_BUFLOST"
    Case 5 : Function = "TBASS_ERROR_HANDLE" 
    Case 6 : Function = "TBASS_ERROR_FORMAT" 
    Case 7 : Function = "TBASS_ERROR_POSITION" 
    Case 8 : Function = "TBASS_ERROR_INIT" 
    Case 9 : Function = "TBASS_ERROR_START" 
    Case 14 : Function = "TBASS_ERROR_ALREADY" 
    Case 16 : Function = "TBASS_ERROR_NOPAUSE" 
    Case 18 : Function = "TBASS_ERROR_NOCHAN" 
    Case 19 : Function = "TBASS_ERROR_ILLTYPE"
    Case 20 : Function = "TBASS_ERROR_ILLPARAM" 
    Case 21 : Function = "TBASS_ERROR_NO3D" 
    Case 22 : Function = "TBASS_ERROR_NOEAX" 
    Case 23 : Function = "TBASS_ERROR_DEVICE" 
    Case 24 : Function = "TBASS_ERROR_NOPLAY" 
    Case 25 : Function = "TBASS_ERROR_FREQ" 
    Case 27 : Function = "TBASS_ERROR_NOTFILE" 
    Case 29 : Function = "TBASS_ERROR_NOHW" 
    Case 31 : Function = "TBASS_ERROR_EMPTY" 
    Case 32 : Function = "TBASS_ERROR_NONET" 
    Case 33 : Function = "TBASS_ERROR_CREATE" 
    Case 34 : Function = "TBASS_ERROR_NOFX" 
    Case 35 : Function = "TBASS_ERROR_PLAYING" 
    Case 37 : Function = "TBASS_ERROR_NOTAVAIL" 
    Case 38 : Function = "TBASS_ERROR_DECODE" 
    Case 39 : Function = "TBASS_ERROR_DX" 
    Case 40 : Function = "TBASS_ERROR_TIMEOUT" 
    Case 41 : Function = "TBASS_ERROR_FILEFORM" 
    Case 42 : Function = "TBASS_ERROR_SPEAKER" 
    Case 43 : Function = "TBASS_ERROR_VERSION" 
    Case 44 : Function = "TBASS_ERROR_CODEC" 
    Case -1 : Function = "TBASS_ERROR_UNKNOWN"
  End Select
  
end function
Documentation:
Description
Converts the passed TBASS error code to human readable explanative string.

Syntax
sString = TBASS_ErrorToString( nError )

Returns
String description of the error.

Parameters
nError;Number;Valid TBASS error code, prefferably returned by TBASS_ErrorGetCode.

Remarks
For valid TBASS error code, the returned string is in form:
"TBASS_ERROR_"(descriptor).

For internal unspecified error, the return value is:
"TBASS_ERROR_UNKNOWN"

Restrictions
If the passed value is outside range of recognisable TBASS error codes, the returned string is in form:
"Unknown error ("+format$(nError)+")"

See also
TBASS_ErrorGetCode

Examples
DIM nError AS LONG

...

nError = TBASS_ErrorGetCode

MSGBOX 0, TBASS_ErrorToString(nError)
Issue Details
Issue Number 283
Issue Type Feature
Project thinBasic
Category Unknown
Status Implemented
Priority 5 - Medium
Suggested Version 1.8.7
Implemented Version 1.9.1
Milestone thinBasic 1.9.0.0
Votes for this feature 0
Votes against this feature 0
Assigned Users (none)
Tags (none)




10-12-2011 22:58
thinBasic author
Developed
Will be present in next release

+ Reply