Improve builder-web setup error messages
Give hints what to do in case the database file does not exist, or when the database is not of the expected version. Addresses #82
This commit is contained in:
parent
1310c35256
commit
f666c9d0d1
1 changed files with 11 additions and 2 deletions
|
@ -126,14 +126,23 @@ let setup_app level influx port host datadir cachedir configdir run_batch_viz_fl
|
||||||
run_batch_viz ~cachedir ~datadir ~configdir
|
run_batch_viz ~cachedir ~datadir ~configdir
|
||||||
in
|
in
|
||||||
match Builder_web.init dbpath datadir with
|
match Builder_web.init dbpath datadir with
|
||||||
|
| exception Sqlite3.Error e ->
|
||||||
|
Format.eprintf "Error: @[@,%s.\
|
||||||
|
@,Does the database file exist? Create with `builder-db migrate`.@]\n%!"
|
||||||
|
e;
|
||||||
|
exit 2
|
||||||
| Error (#Caqti_error.load as e) ->
|
| Error (#Caqti_error.load as e) ->
|
||||||
Format.eprintf "Error: %a\n%!" Caqti_error.pp e;
|
Format.eprintf "Error: %a\n%!" Caqti_error.pp e;
|
||||||
exit 2
|
exit 2
|
||||||
|
| Error (`Wrong_version _ as e) ->
|
||||||
|
Format.eprintf "Error: @[@,%a.\
|
||||||
|
@,Migrate database version with `builder-migrations`,\
|
||||||
|
@,or start with a fresh database with `builder-db migrate`.@]\n%!"
|
||||||
|
Builder_web.pp_error e;
|
||||||
| Error (
|
| Error (
|
||||||
#Caqti_error.connect
|
#Caqti_error.connect
|
||||||
| #Caqti_error.call_or_retrieve
|
| #Caqti_error.call_or_retrieve
|
||||||
| `Msg _
|
| `Msg _ as e
|
||||||
| `Wrong_version _ as e
|
|
||||||
) ->
|
) ->
|
||||||
Format.eprintf "Error: %a\n%!" Builder_web.pp_error e;
|
Format.eprintf "Error: %a\n%!" Builder_web.pp_error e;
|
||||||
exit 1
|
exit 1
|
||||||
|
|
Loading…
Reference in a new issue