diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2020-12-08 21:16:10 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-08 21:16:10 +0100 |
commit | f2eb23cd87cf32b8fe545178143b5f49e06a58da (patch) | |
tree | af7d59945af70e28fd85047e2c688c59a908f548 /server/tools | |
parent | c977fd3ec931c059111ddb2b8d6ddbb20b6b99a1 (diff) | |
download | PeerTube-f2eb23cd87cf32b8fe545178143b5f49e06a58da.tar.gz PeerTube-f2eb23cd87cf32b8fe545178143b5f49e06a58da.tar.zst PeerTube-f2eb23cd87cf32b8fe545178143b5f49e06a58da.zip |
emit more specific status codes on video upload (#3423)
- reduce http status codes list to potentially useful codes
- convert more codes to typed ones
- factorize html generator for error responses
Diffstat (limited to 'server/tools')
-rw-r--r-- | server/tools/peertube-redundancy.ts | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/server/tools/peertube-redundancy.ts b/server/tools/peertube-redundancy.ts index 1ab58a438..fe482daf4 100644 --- a/server/tools/peertube-redundancy.ts +++ b/server/tools/peertube-redundancy.ts | |||
@@ -7,6 +7,7 @@ import * as program from 'commander' | |||
7 | import { getAdminTokenOrDie, getServerCredentials } from './cli' | 7 | import { getAdminTokenOrDie, getServerCredentials } from './cli' |
8 | import { VideoRedundanciesTarget, VideoRedundancy } from '@shared/models' | 8 | import { VideoRedundanciesTarget, VideoRedundancy } from '@shared/models' |
9 | import { addVideoRedundancy, listVideoRedundancies, removeVideoRedundancy } from '@shared/extra-utils/server/redundancy' | 9 | import { addVideoRedundancy, listVideoRedundancies, removeVideoRedundancy } from '@shared/extra-utils/server/redundancy' |
10 | import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' | ||
10 | import validator from 'validator' | 11 | import validator from 'validator' |
11 | import * as CliTable3 from 'cli-table3' | 12 | import * as CliTable3 from 'cli-table3' |
12 | import { URL } from 'url' | 13 | import { URL } from 'url' |
@@ -124,9 +125,9 @@ async function addRedundancyCLI (options: { videoId: number }) { | |||
124 | 125 | ||
125 | process.exit(0) | 126 | process.exit(0) |
126 | } catch (err) { | 127 | } catch (err) { |
127 | if (err.message.includes(409)) { | 128 | if (err.message.includes(HttpStatusCode.CONFLICT_409)) { |
128 | console.error('This video is already duplicated by your instance.') | 129 | console.error('This video is already duplicated by your instance.') |
129 | } else if (err.message.includes(404)) { | 130 | } else if (err.message.includes(HttpStatusCode.NOT_FOUND_404)) { |
130 | console.error('This video id does not exist.') | 131 | console.error('This video id does not exist.') |
131 | } else { | 132 | } else { |
132 | console.error(err) | 133 | console.error(err) |