PHP exceptions: where to put dynamic data? -



PHP exceptions: where to put dynamic data? -

i'm in process of rewriting error handling of pear's text_languagedetect exceptions , don't know dynamic info in exceptions:

throw new text_languagedetect_exception( 'language database not exist.', text_languagedetect_exception::db_not_found );

here i'd include file name tried opened, question where set it:

language database /path/to/file.ext not exist. language database "/path/to/file.ext" not exist. language database not exist: /path/to/file.ext language database not exist: "/path/to/file.ext"

1+2 proper english language sentences, while 3+4 create easy grep message in code. also, extracting file name code easier in 3+4.

which 1 should use, why?

another question is: should set file name?

when set exception message, may give attackers info file construction on server if sees message. without file name, it's harder debug.

you should utilize message format seems more readable you. it's not practice rely on exception message in code. if need it, should subclass exception instead.

second question: should not display detailed errors users in production environment, don't see including filename problem.

php exception

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -