@@ -264,7 +264,7 @@ function create_or_update_project(Project $project)
264264
265265 $ project ->validate (true );
266266 } catch (ProjectException $ exception ) {
267- throw new InvalidValue ($ exception-> getMessage (), $ exception -> getCode () );
267+ throw InvalidValue:: fromException ($ exception );
268268 }
269269
270270 // validate charsuites
@@ -513,7 +513,7 @@ function api_v1_project_pages(string $method, array $data)
513513 ];
514514 }
515515 } catch (NoProjectPageTable $ exception ) {
516- throw new NotFoundError ($ exception-> getMessage (), $ exception -> getCode () );
516+ throw NotFoundError:: fromException ($ exception );
517517 }
518518 return $ return_data ;
519519}
@@ -545,7 +545,7 @@ function api_v1_project_pagedetails(string $method, array $data, array $query_pa
545545 try {
546546 $ rounds_to_display = get_rounds_to_display ($ project );
547547 } catch (NoProjectPageTable $ exception ) {
548- throw new NotFoundError ($ exception-> getMessage (), $ exception -> getCode () );
548+ throw NotFoundError:: fromException ($ exception );
549549 }
550550 if (!is_null ($ only_rounds )) {
551551 $ rounds_to_display = array_intersect ($ rounds_to_display , $ only_rounds );
@@ -849,9 +849,9 @@ function api_v1_project_checkout(string $method, array $data, array $query_param
849849 $ proof_project = new ProofProject ($ project );
850850 return $ proof_project ->checkout ();
851851 } catch (ProjectException $ exception ) {
852- throw new NotFoundError ($ exception-> getMessage (), $ exception -> getCode () );
852+ throw NotFoundError:: fromException ($ exception );
853853 } catch (UserAccessException $ exception ) {
854- throw new ForbiddenError ($ exception-> getMessage (), $ exception -> getCode () );
854+ throw ForbiddenError:: fromException ($ exception );
855855 }
856856}
857857
@@ -933,9 +933,9 @@ function api_v1_project_page(string $method, array $data, array $query_params)
933933 throw new BadRequest ("$ page_action is not a valid page action. " );
934934 }
935935 } catch (ProjectException $ exception ) {
936- throw new NotFoundError ($ exception-> getMessage (), $ exception -> getCode () );
936+ throw NotFoundError:: fromException ($ exception );
937937 } catch (UserAccessException $ exception ) {
938- throw new ForbiddenError ($ exception-> getMessage (), $ exception -> getCode () );
938+ throw ForbiddenError:: fromException ($ exception );
939939 }
940940}
941941
@@ -950,9 +950,9 @@ function api_v1_project_page_format_preview(string $method, array $data): void
950950
951951 $ proof_project_page ->fp_report ();
952952 } catch (ProjectException $ exception ) {
953- throw new NotFoundError ($ exception-> getMessage (), $ exception -> getCode () );
953+ throw NotFoundError:: fromException ($ exception );
954954 } catch (UserAccessException $ exception ) {
955- throw new ForbiddenError ($ exception-> getMessage (), $ exception -> getCode () );
955+ throw ForbiddenError:: fromException ($ exception );
956956 }
957957}
958958
@@ -976,11 +976,11 @@ function api_v1_project_page_report_bad(string $method, array $data): void
976976 }
977977 $ proof_project_page ->markAsBad ($ pguser , $ reason_key );
978978 } catch (ProjectTransitionException $ exception ) {
979- throw new UnexpectedError ($ exception-> getMessage (), $ exception -> getCode () );
979+ throw UnexpectedError:: fromException ($ exception );
980980 } catch (ProjectException $ exception ) {
981- throw new BadRequest ($ exception-> getMessage (), $ exception -> getCode () );
981+ throw BadRequest:: fromException ($ exception );
982982 } catch (UserAccessException $ exception ) {
983- throw new ForbiddenError ($ exception-> getMessage (), $ exception -> getCode () );
983+ throw ForbiddenError:: fromException ($ exception );
984984 }
985985}
986986
@@ -995,9 +995,9 @@ function api_v1_project_page_wordcheck(string $method, array $data): void
995995
996996 $ proof_project_page ->wc_report (receive_data_from_request_body ("accepted_words " ) ?? []);
997997 } catch (ProjectException $ exception ) {
998- throw new NotFoundError ($ exception-> getMessage (), $ exception -> getCode () );
998+ throw NotFoundError:: fromException ($ exception );
999999 } catch (UserAccessException $ exception ) {
1000- throw new ForbiddenError ($ exception-> getMessage (), $ exception -> getCode () );
1000+ throw ForbiddenError:: fromException ($ exception );
10011001 }
10021002}
10031003
0 commit comments