Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Wyjątki - Uncaught exception 'Exception' with message, Wywala błąd
Joachim Peters
post 16.07.2007, 09:52:26
Post #1





Grupa: Zarejestrowani
Postów: 196
Pomógł: 2
Dołączył: 1.03.2006

Ostrzeżenie: (0%)
-----


Wywala mi coś takiego:
  1. <?php
  2. Fatal error: Uncaught exception 'Exception' with message 'bład' in /home/ddd/public_html/test/upload.php:45 Stack trace: #0 /home/ddd/public_html/test/upload.php(73): Upload->checkFile() #1 {main} thrown in /home/ddd/public_html/test/upload.php on line 45
  3. ?>


linia z wyjątkiem w klasie wygląda tak:
  1. <?php
  2. throw new Exception('bład');
  3. ?>


łapanie wyjątku tak:
  1. <?php
  2. try {
  3. $upload = new Upload();
  4.  
  5. if(isset($_POST['submit'])) {
  6. $upload->setFile($_FILES['file']['tmp_name']);
  7. $upload->setFileName($_FILES['file']['name']);
  8. $upload->setFileSize($_FILES['file']['size']);
  9.  
  10. if($upload->checkFile()) {
  11. $upload->uploadFile();
  12. }
  13. }
  14. } catch(Exception $e) {
  15. echo('Wyjątek mówi: '.$e->getMessage());
  16. }
  17. ?>


Co jest nie tak?
Go to the top of the page
+Quote Post
Luke_Star
post 16.07.2007, 10:07:39
Post #2





Grupa: Zarejestrowani
Postów: 129
Pomógł: 2
Dołączył: 17.01.2005

Ostrzeżenie: (0%)
-----


a zainkludowales klase exepction?


--------------------
Słowa, słowa, słowa... - Hamlet || Funkcje, funkcje, funkcje... - Luke Star
--------------------------------------
Portal Literacki: ( |||------- ) 30%
Go to the top of the page
+Quote Post
Joachim Peters
post 16.07.2007, 13:24:24
Post #3





Grupa: Zarejestrowani
Postów: 196
Pomógł: 2
Dołączył: 1.03.2006

Ostrzeżenie: (0%)
-----


Hmm? Jak?
Go to the top of the page
+Quote Post
Cysiaczek
post 16.07.2007, 13:28:32
Post #4





Grupa: Moderatorzy
Postów: 4 465
Pomógł: 137
Dołączył: 26.03.2004
Skąd: Gorzów Wlkp.




Trochę to dziwne - przyznam. : |
Zobacz, co pokaże $e->getTrace(), albo $e-> __toString(), choć wątpię... jaka wersja php?

@Luke_Star - to jest klasa dostepna natywnie w php.

Ten post edytował Cysiaczek 16.07.2007, 13:29:18


--------------------
To think for yourself you must question authority and
learn how to put yourself in a state of vulnerable, open-mindedness;
chaotic, confused, vulnerability, to inform yourself.
Think for yourself. Question authority.
Go to the top of the page
+Quote Post
pawel_k
post 27.07.2007, 11:12:14
Post #5





Grupa: Zarejestrowani
Postów: 211
Pomógł: 3
Dołączył: 29.07.2005
Skąd: Szczebrzeszyn

Ostrzeżenie: (0%)
-----


kod:
  1. <?php
  2. try
  3. {
  4. throw new Exception('aaa');
  5. }
  6. catch( Exception $e)
  7. {
  8. var_dump($e->getMessage());
  9. }
  10. ?>

wynik:
  1. <?php
  2. Fatal error: Uncaught exception 'Exception' with message 'aaa' in (...)
  3. ?>

php 5.2.3 w wersji fastcgi, debian 4.0
co dziwne pod cli na tej samej maszynie działa (php też w wersji 5.2.3)
ktoś wie o co chodzi?

[edit]
no i mamy winnego
http://eaccelerator.net/ticket/242

Ten post edytował pawel_k 27.07.2007, 11:12:28
Go to the top of the page
+Quote Post
eMCeH
post 7.12.2012, 11:33:21
Post #6





Grupa: Zarejestrowani
Postów: 48
Pomógł: 1
Dołączył: 1.04.2012
Skąd: Świętokrzyskie

Ostrzeżenie: (0%)
-----


link nie działa, napisz jak sobie z tym poradziłeś, ja mam podobny problem:

  1. function sprawdz_liczbe_kolumn(){
  2. try {
  3. $highestColumm = $objPHPExcel->setActiveSheetIndex(0)->getHighestColumn();
  4. $highestRow = $objPHPExcel->setActiveSheetIndex(0)->getHighestRow();
  5. } catch (Exception $e) {
  6. echo $e;
  7. echo '<br /> UWAGA!!! PLIK USZKODZONY - proszę spróbować odczytać go programem Excel, zapisać pod inna nazwą i ponownie wysłać';
  8. return FALSE;
  9. }
  10.  
  11. }



wyjątek nie jest przechwytywany zamiast niego komunikat : 'Fatal error: Uncaught exception 'Exception' with message 'Active sheet index is out of bounds.'

Ten post edytował eMCeH 7.12.2012, 11:34:05
Go to the top of the page
+Quote Post
wiiir
post 7.12.2012, 22:01:42
Post #7





Grupa: Zarejestrowani
Postów: 260
Pomógł: 34
Dołączył: 22.02.2010

Ostrzeżenie: (0%)
-----


sprawdz
throw new \Exception('aaa');
Go to the top of the page
+Quote Post
wNogachSpisz
post 8.12.2012, 00:06:29
Post #8





Grupa: Zarejestrowani
Postów: 1 233
Pomógł: 87
Dołączył: 6.03.2009

Ostrzeżenie: (40%)
XX---


Description a thrown exception will not be catched, if a there is a user defined exception class.
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 29.06.2025 - 21:13