2017-03-16 3 views
0

저는 Minecraft mod에서 GitHub 문제 페이지로 예외를 자동으로보고하기 위해 오류 리포터를 작성했습니다. 그것은 작동하지만 문제가 이미 존재하는지 확인하는 코드가 작동하지 않습니다. GitHub와의 상호 작용에 jcabi을 사용하고 있습니다. 추가 정보가 필요하면 알려주십시오. 감사!GitHub 이슈가 이미 존재하는지 확인하십시오.

private static Github github = new RtGithub(Secure.Token); 
private static Repo repo = github.repos().get(new Coordinates.Simple("SneakyTactician/BIGB2")); 

public static void Report(Exception ToReport) 
{ 
    try 
    {  
     //The title for the issue. 
     String Title = ToReport.getMessage(); 
     //Generates a message for the issue. 
     String Report = GetMessage(ToReport); 

     if (!DoesIssueAlreadyExist(Title, Report)) 
     { 

     Issue TheIssue = repo.issues().create(Title, Report); 
     Issue.Smart a = new Issue.Smart(TheIssue); 
     a.assign("SneakyTactician"); 

     a.labels().add(extracted()); 
     } 
    } 
    catch (IOException e) 
    { 
     e.printStackTrace(); 
    } 
} 

예 문제 제목 :

/제로하여 메시지 생성 및 문제 창조의 내 프로세스를 시작

private static boolean DoesIssueAlreadyExist(String Title, String Report) 
{ 
    try 
    { 
     int i = 0; 
     int size = GetNumberOfIssues(); 
     Issue.Smart Current; 

     while (i != size) 
     { 
      Current = new Issue.Smart(repo.issues().get(i)); 

      if (Current.title() == Title && Current.body() == Report) 
      { 
        return true; 
      } 

      i++; 
     } 

     return false; 

    } 
    catch (Exception e) 
    { 
     e.printStackTrace(); 
     return false; 
    } 
} 

코드 : 문제가 이미 존재하는 경우를 결정

코드

예제 발행 본 :

개조의 6,
java.lang.ArithmeticException:/by zero 
at sneaky.main.Startup.preInit(Startup.java:28) 
at sneaky.main.BIGB2.preInit(BIGB2.java:21) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
at java.lang.reflect.Method.invoke(Method.java:483) 
at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:641) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
at java.lang.reflect.Method.invoke(Method.java:483) 
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) 
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) 
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) 
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) 
at com.google.common.eventbus.EventBus.post(EventBus.java:275) 
at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:246) 
at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:224) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
at java.lang.reflect.Method.invoke(Method.java:483) 
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) 
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) 
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) 
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) 
at com.google.common.eventbus.EventBus.post(EventBus.java:275) 
at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:147) 
at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:628) 
at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:268) 
at net.minecraft.client.Minecraft.func_71384_a(Minecraft.java:440) 
at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:352) 
at net.minecraft.client.main.Main.main(SourceFile:124) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
at java.lang.reflect.Method.invoke(Method.java:483) 
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) 
at net.minecraft.launchwrapper.Launch.main(Launch.java:28) 

6number 발견 된 실행 :

마인 크래프트 1.11.2

마인 크래프트 코더 팩 9.19

포지 모 로더 8.0.99.99

마인 크래프트 포지 13.20.0.2228

mercurius_updater 1.0

나는 지루했기 때문에

답변

0

많은 시간 동안의 난감함과 좌절감으로, 나는 그것을 알아 냈다! 아래의 방법은 GitHub 문제 페이지에 이미 문제가 있는지 확인합니다.

/** 
* Determines if the exception has already been posted to the issue page. 
* Returns false if an error occurs. 
* @param e 
* @return 
*/ 
private static boolean DoesIssueAlreadyExist(String Title, String Report) 
{ 
    try 
    { 
     EnumMap<Qualifier, String> qualifiers = new EnumMap<Qualifier, String>(Issues.Qualifier.class); 

     Iterable<Issue> Issues = repo.issues().search(Sort.CREATED, Order.DESC, qualifiers); 

     Issue.Smart current; 

     long size = Iterables.size(Issues); 

     int i = 0; 


     while (i != size) 
     { 
      current = new Issue.Smart(Issues.iterator().next()); 

      if (current.title().contains(Title) && current.body().contains(Report)) 
      { 
       return true; 
      } 

      i++; 
     } 

     return false; 

    } 
    catch (Exception e) 
    { 
     e.printStackTrace(); 
     return true; 
    } 
}