Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
sms-gateway
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
David Huss
sms-gateway
Commits
e06f5c8f
Commit
e06f5c8f
authored
2 years ago
by
David Huss
Browse files
Options
Downloads
Patches
Plain Diff
Fix error with eventhandler
parent
5165d381
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
Cargo.lock
+1
-1
1 addition, 1 deletion
Cargo.lock
Cargo.toml
+1
-1
1 addition, 1 deletion
Cargo.toml
src/bin/eventhandler.rs
+9
-3
9 additions, 3 deletions
src/bin/eventhandler.rs
src/errors.rs
+4
-0
4 additions, 0 deletions
src/errors.rs
with
15 additions
and
5 deletions
Cargo.lock
+
1
−
1
View file @
e06f5c8f
...
...
@@ -1376,7 +1376,7 @@ checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0"
[[package]]
name = "sms-gateway"
version = "0.
3.2
"
version = "0.
4.0
"
dependencies = [
"actix-rt",
"actix-web",
...
...
This diff is collapsed.
Click to expand it.
Cargo.toml
+
1
−
1
View file @
e06f5c8f
...
...
@@ -2,7 +2,7 @@
name
=
"sms-gateway"
description
=
"A http frontend for SMS Server Tools 3"
authors
=
[
"David Huss <david.huss@hfbk-hamburg.de>"
]
version
=
"0.4.
0
"
version
=
"0.4.
1
"
edition
=
"2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
...
...
This diff is collapsed.
Click to expand it.
src/bin/eventhandler.rs
+
9
−
3
View file @
e06f5c8f
...
...
@@ -31,10 +31,16 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
match
args
.len
()
{
2
|
3
=>
{
let
kind
=
args
[
0
]
.to_ascii_lowercase
();
let
path
=
PathBuf
::
from
(
&
args
[
1
]);
let
kind
=
args
[
1
]
.to_ascii_lowercase
();
let
path
=
PathBuf
::
from
(
&
args
[
2
]);
let
content
=
std
::
fs
::
read_to_string
(
&
path
)
?
;
let
content
=
match
std
::
fs
::
read_to_string
(
&
path
)
{
Ok
(
s
)
=>
s
,
Err
(
e
)
=>
{
error!
(
"Could not read {} SMS from path
\"
{}
\"
: {}"
,
kind
,
path
.to_string_lossy
(),
e
);
exit
(
1
);
}
};
match
&
kind
[
..
]
{
"received"
=>
{
...
...
This diff is collapsed.
Click to expand it.
src/errors.rs
+
4
−
0
View file @
e06f5c8f
...
...
@@ -15,6 +15,8 @@ pub enum SmsError {
InvalidCharacters
,
#[error(
"Could not write the SMS to the outgoing directory: '{0}'"
)]
WriteError
(
String
),
#[error(
"Could not read SMS at path
\"
{0}
\"
: {1}"
)]
ReadError
(
String
,
String
),
#[error(
"Received Event of unknown kind: '{0}'"
)]
UnknownEventKind
(
String
),
#[error(
"Failed to deserialize SMS from string: '{0}'"
)]
...
...
@@ -33,6 +35,7 @@ impl SmsError {
SmsError
::
InvaldNumber
(
_s
)
=>
"Bad Request"
.to_string
(),
SmsError
::
InvalidCharacters
=>
"Bad Request"
.to_string
(),
SmsError
::
WriteError
(
_s
)
=>
"Internal Server Error"
.to_string
(),
SmsError
::
ReadError
(
_s
,
_x
)
=>
"Internal Server Error"
.to_string
(),
SmsError
::
UnknownEventKind
(
_s
)
=>
"Internal Server Error"
.to_string
(),
SmsError
::
DeserializationError
(
_s
)
=>
"Internal Server Error"
.to_string
(),
SmsError
::
NotInWhiteList
(
_
)
=>
"Forbidden"
.to_string
(),
...
...
@@ -60,6 +63,7 @@ impl ResponseError for SmsError {
SmsError
::
InvaldNumber
(
_
)
=>
StatusCode
::
BAD_REQUEST
,
SmsError
::
InvalidCharacters
=>
StatusCode
::
BAD_REQUEST
,
SmsError
::
WriteError
(
_
)
=>
StatusCode
::
INTERNAL_SERVER_ERROR
,
SmsError
::
ReadError
(
..
)
=>
StatusCode
::
INTERNAL_SERVER_ERROR
,
SmsError
::
UnknownEventKind
(
_
)
=>
StatusCode
::
INTERNAL_SERVER_ERROR
,
SmsError
::
DeserializationError
(
_
)
=>
StatusCode
::
INTERNAL_SERVER_ERROR
,
SmsError
::
NotInWhiteList
(
_
)
=>
StatusCode
::
FORBIDDEN
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment