-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add generic error msg for unknown source errors (#645)
This is a little enhancement when the source plugin fails and raises an exception without message. Also extends the source plugin development guide. Related with https://issues.redhat.com/browse/AAP-19598
- Loading branch information
1 parent
3396470
commit a554c80
Showing
7 changed files
with
121 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
- name: "89 source error with msg" | ||
hosts: all | ||
sources: | ||
- name: range_fail_with_msg | ||
source_with_exception: | ||
error_msg: "range fail with msg" | ||
rules: | ||
- name: r1 | ||
condition: true | ||
action: | ||
print_event: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
- name: "90 source error without msg" | ||
hosts: all | ||
sources: | ||
- name: range_fail_without_msg | ||
source_with_exception: | ||
error_msg: "" | ||
rules: | ||
- name: r1 | ||
condition: true | ||
action: | ||
print_event: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Copyright 2022 Red Hat, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import asyncio | ||
from typing import Any, Dict | ||
|
||
|
||
class TestException(Exception): | ||
pass | ||
|
||
|
||
async def main(queue: asyncio.Queue, args: Dict[str, Any]): | ||
error_msg = str(args.get("error_msg", "")) | ||
raise TestException(error_msg) | ||
|
||
|
||
if __name__ == "__main__": | ||
|
||
class MockQueue: | ||
async def put(self, event): | ||
print(event) | ||
|
||
asyncio.run(main(MockQueue(), dict(limit=5))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters